Questions tagged [qtoolbutton]

In Qt, the QToolButton class provides a quick-access button to commands or options, usually used inside a QToolBar.

This is a part of the QtGui library

Detailed Description

The QToolButton class provides a quick-access button to commands or options, usually used inside a QToolBar.

A tool button is a special button that provides quick-access to specific commands or options. As opposed to a normal command button, a tool button usually doesn't show a text label, but shows an icon instead. Tool buttons are normally created when new QAction instances are created with QToolBar::addAction() or existing actions are added to a toolbar with QToolBar::addAction(). It is also possible to construct tool buttons in the same way as any other widget, and arrange them alongside other widgets in layouts. One classic use of a tool button is to select tools; for example, the "pen" tool in a drawing program. This would be implemented by using a QToolButton as a toggle button (see setToggleButton()).

QToolButton supports auto-raising. In auto-raise mode, the button draws a 3D frame only when the mouse points at it. The feature is automatically turned on when a button is used inside a QToolBar. Change it with setAutoRaise(). A tool button's icon is set as QIcon. This makes it possible to specify different pixmaps for the disabled and active state. The disabled pixmap is used when the button's functionality is not available. The active pixmap is displayed when the button is auto-raised because the mouse pointer is hovering over it. The button's look and dimension is adjustable with setToolButtonStyle() and setIconSize(). When used inside a QToolBar in a QMainWindow, the button automatically adjusts to QMainWindow's settings (see

QMainWindow::setToolButtonStyle() and QMainWindow::setIconSize()). Instead of an icon, a tool button can also display an arrow symbol, specified with arrowType. A tool button can offer additional choices in a popup menu. The popup menu can be set using setMenu(). Use setPopupMode() to configure the different modes available for tool buttons with a menu set. The default mode is DelayedPopupMode which is sometimes used with the "Back" button in a web browser. After pressing and holding the button down for a while, a menu pops up showing a list of possible pages to jump to. The default delay is 600 ms; you can adjust it with setPopupDelay().

Qt Documentation

55 questions
42
votes
2 answers

Difference between QPushButton and QToolButton

I'm new to Qt and the difference between QPushButton and QToolButton is not so clear to me. I know that a QToolButton is usually used in a QToolBar and it usually shows only an icon, without text, but I don't quite understand the main difference…
KelvinS
  • 2,870
  • 8
  • 34
  • 67
10
votes
1 answer

QToolButton not visible in windows

I have derived the class of QTabBar to implement "+" (new tab button) button using QToolButton (similar to google chrome). However, it is working in my Linux machine but doesn't work in my windows machine. By not working I mean QToolButton is not…
abhiarora
  • 9,743
  • 5
  • 32
  • 57
6
votes
6 answers

How to insert a button inside a QLineEdit

I need help inserting a button inside in a QLineEdit that can call a function. For example, like this google image:
Andrew Zhuk
  • 500
  • 8
  • 23
4
votes
1 answer

Python Create a real circle button in pyqt5

I try to create a circle button but in fact pyqt still creates a square button.All examples found just creates square buttons and put a round image in it but still when i try to hide background of the button it fails.I also try to add some hover…
4
votes
0 answers

How can I set word wrapping in QToolButton's text?

I want to show some text in a QToolButton derived class but it needs to be word wrapped. I would like to do it in an "automatic" way (instead of using \n when needed) just as one can do it when using QLabel and setting word wrapp to true, but I…
Momergil
  • 2,213
  • 5
  • 29
  • 59
3
votes
0 answers

How to make circle shape QToolButton with outside border?

I have implemented some circle shape QToolButtons using stylesheets; everything is working fine, except that I haven't found a way to add an outside border instead. At the moment QT only supports CSS 2 meaning that I'm not able to use the box-shadow…
3
votes
1 answer

How can I add custom widget as Popup menu for ToolButton?

I have created a custom Widget,it has to be displayed as a popup menu when click on the ToolButton. How I can do this in Qt 5.1.1?
Suresh R
  • 85
  • 6
2
votes
1 answer

Qt - Create Button with images which fade out & fade in in parallel on hoverEvent

In C++/Qt6, I would like to develop a button with an animation (I imagine that I'll have to use QParallelAnimationGroup) which fade out an image in parallel of a fade in another image as the icon of the button. Here is what I want (made with a movie…
2
votes
1 answer

How to customize QToolButtons from QToolBar in Qt?

I am having QToolBar with various tool buttons on it. I want to customize those buttons with some simple effects like, it should be seen that button is pressed, after pressing it should change its icon color or background color etc. I tried but I…
tushar
  • 313
  • 4
  • 10
2
votes
1 answer

How can I make the right margin in QToolButton for the indicator?

I have QToolButton with left icon and right indicator (MenuButtonPopup mode). How do I change this distance by qss? Attention to the picture tool button:
igorotvertka
  • 87
  • 1
  • 7
2
votes
1 answer

How to properly manage text and icon with QToolButton?

I have code snippet looks like this: nextPageBtn = new QToolButton(); nextPageBtn->setSizePolicy(QSizePolicy::Expanding,…
Theodore Tang
  • 831
  • 2
  • 21
  • 42
1
vote
1 answer

How to center QToolButton icon?

when I connect a Qt QToolButton to a QAction that has an icon assigned to it, the icon shows in the QToolButton, but the icon is off-center and misaligned, see the image below: I am setting up the buttons like this (Python…
1
vote
1 answer

Button is not clickable when window is small

I'm creating an expandable/collapsible widget because Qt doesn't provide such feature until now. My problem is, that the button to expand/collapse the widget seems to be only clickable, if you make the window very large (only the width of the window…
user14842633
1
vote
1 answer

display two color font on QToolButton

I want a button that shows a text with two colors. I've tried the following: import sys from PyQt4 import QtCore,QtGui class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() …
stdcerr
  • 13,725
  • 25
  • 71
  • 128
1
vote
1 answer

How to connect Qtoolbutton and QStackedWidget (Both are in same frame)

I created a Window in which there are 4 different QToolButtons and it is outside QStackedWidget. When I click on the first QToolButton which is Balance Inquiry as shown in the image then the contents of Balance Inquiry should be shown and similarly…
1
2 3 4