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
0
votes
0 answers

Setting a QSS style on all QToolButtons in an application except the ones inside a QToolBar

The application I am working on uses QToolButtons as simple elements in a layout and as QActions added to QToolBars. I would like to apply a style on all the QToolButtons in my application except the ones within a QToolBar. I saw that I can set a…
sajas
  • 1,599
  • 1
  • 17
  • 39
0
votes
0 answers

How to resize focus area of a QToolButton?

I've got a QToolbar with QToolButtons. The buttons receive focus with a manual ->setFocus(). However I need the focus marking area (blue) to be expanded to the size of the full area as while hovered. Is there a way to do that? Hover + focus Focus…
Mykola Tetiuk
  • 157
  • 3
  • 9
0
votes
0 answers

Adding checkable QToolButton to QToolBar with an icon, a text and a menu

Currently, I have a QToolBar with different checkable actions grouped in QActionGroups set to autoExclusive. This works well. Now, I would like to have one QAction with a menu so that user can choose the behavior of this action. So I decided to use…
zigma12
  • 181
  • 1
  • 7
0
votes
0 answers

Manually setting the geometry of a QToolbutton messes with the clickable area of it

The idea that I am looking to apply in my code is the create an "Add Tab" button in my tab bar. The likes of which can be seen in any browser like chrome. This requires that I must update the position of the button depending on what is the last tab…
0
votes
1 answer

How can I place multiple QToolButton one after the other, instead of being one below the other

I am working on a QT project that makes it possible to view and edit table views from a given file. For the buttons in the GUI I'm using QToolButton, but when more than one button is created, they are placed one below the other, whereas I would like…
0
votes
1 answer

QToolButton with popup QSlider

I'm trying to make volume button, on click it should mute/unmute and and on hover it should popup QSlider, so user can set whatever level he wants. Now I'm trying to achieve this by showing slider window in enterEvent and hiding it in…
JuicyKitty
  • 318
  • 1
  • 16
0
votes
1 answer

PyQt QToolButton not updating icon when in focus

I'm having a problem updating the icon of a button set with QToolButton. The idea is to use the button for a movie player. To play, one presses the button and the icon changes to pause. When pressed again, play is paused and the icon reverts to…
tiago
  • 22,602
  • 12
  • 72
  • 88
0
votes
1 answer

How to ignore the first mouse event in the QToolButton Menu to prevent unwanted selection of items

A colleague made a custom QMenu derivative so that one can select multiple entries before the menu closes. It is triggered via a QToolButton. The problem is if the menu is large enough it will overlap with the button. The item at the current cursor…
Raphael
  • 810
  • 6
  • 18
0
votes
0 answers

QToolbutton text overlapping menu button

When having a long text applied to a QToolbutton it overlaps the menu button for the right click menu like the following: The code for the Button TestWindow::TestWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::TestWindow) { …
easysaesch
  • 159
  • 1
  • 14
0
votes
1 answer

Unable to increase size of QToolButton (with Button style set to Qt::ToolButtonTextBesideIcon)

I have a small qt application written in c++. I want the same application to run in small embedded device with a touchscreen but the size of few QToolButton was too small to be visible comfortably. I have tired to increase the size by modifying…
abhiarora
  • 9,743
  • 5
  • 32
  • 57
0
votes
1 answer

Is it possible to style a checked QToolButton using QSS?

Obviously, this applies only to checkable QToolButtons. The light blue background and border isn't as nice on my app as a light red background. (The code below has red background just as an example.) I've tried: QToolButton:pressed { …
Osama Kawish
  • 312
  • 1
  • 5
  • 15
0
votes
1 answer

autoexclusive tool buttons in Qt

Here I come up with my another question and this time regarding Qt Tool Buttons AutoExclusive property. Please find my question below: Q) I have 4 tool buttons which are autoExclusive to each other but the problem I am facing is when I want deselect…
0
votes
1 answer

How to set QToolButton fill in the side bar(QDockWidget) in Qt?

I wrote a minimal example which has a sidebar which contains a QToolButton on it. I set setAutoRaise(true) for the QToolButton, so when hover on it, the button will raise. But currently I have a minor issue. As you can see from the picture below,…
Theodore Tang
  • 831
  • 2
  • 21
  • 42
0
votes
2 answers

QToolButton prevent from moving

Is there a way to prevent QToolButton from being "pressed in" when clicked? I read somewhere that setting button->setCheckable(false); should do the trick, but it doesn't.
madasionka
  • 812
  • 2
  • 10
  • 29
0
votes
1 answer

Position of a QToolButton does not change when resizing or moving the parent widget

I have a class called Titlebar inherited from QWidget. The following code goes inside the constructor of Titlebar class: m_queueBtn = new QToolButton; m_serverToolBar = new QToolBar; m_serverToolBar->addWidget(m_queueBtn); QPoint pos =…
Sijith
  • 3,740
  • 17
  • 61
  • 101