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
1
vote
2 answers

QToolButton Remain Pressed after finger has been removed from Touchscreen

I have a small Qt Desktop application (in C++) which I need to make it work in a touch screen device running Window 10. The device has a touchscreen and application works perfectly with keyboard and mouse. I am not expert in developing Qt…
abhiarora
  • 9,743
  • 5
  • 32
  • 57
1
vote
0 answers

How to add 2 custom buttons for QLineEdit?

I tried to add two buttons for my line edit. The "clear" appears only when the text in line edit not empty, and the "bulb" is always shown. MyLineEdit.cpp MyLineEdit::MyLineEdit( QWidget *p_parent ) : QLineEdit( p_parent ) { m_buttonAction =…
songvan
  • 369
  • 5
  • 21
1
vote
1 answer

QToolButton clicked signal is only called once

I have attached a QMenu to the QToolButton in which the Menu is not reflecting correctly. I am populating my QMenu from reading a .txt file. The menu is showing the correct items on the first run, but if I made changes in the .txt file and…
Teh Ki
  • 455
  • 1
  • 3
  • 14
1
vote
0 answers

How can i add a Tool Buttons for Mayavi pipeline options

Here is my mayavi program,in that mayavi pipeline have several options i.e like volume and Colors and legends, i want to add those options to right side of my plot as a tool buttons, because directly i want to change my setting on my plot i don't…
rama
  • 43
  • 8
1
vote
1 answer

How to make size of button in the LineEdit smaller?

I made the X button in the LineEdit, when i click on this button, the LineEdit is clear. But with my method, the X button looks a little big and not beautiful, I need to make it smaller. How I can do it? myLineEdit = new…
songvan
  • 369
  • 5
  • 21
1
vote
1 answer

I created a QToolButton and the label would include "..." but it looks like Qt removes them, is that right?

I use the following code, the first part, creating the QToolButton, is from Designer/moc, the rest I added. // Moc part QToolButton * f_tool_button = new…
Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
1
vote
0 answers

One QMenu for all QToolButton

I've created QToolBar which contains few QToolButton. Each QToolButton has QMenu which is one for all. And this menu has few actions. Ugly example: QToolBar bar; QMenu menu; QAction action1; menu.addAction(action1); QAction…
1
vote
1 answer

How to center an icon in a QToolButton?

I created a simple 10x10 black box and added it to a QToolButton as follows: QIcon minIcon; minIcon.addFile("c:/tmp/black10x10.png"); minButton = new QToolButton; minButton->setIcon(minIcon); However, it appears on screen shifted left (image…
sigil
  • 815
  • 8
  • 16
1
vote
0 answers

QToolButton Not Appearing/Overlapping

I am dynamically adding QToolButtons to my toolbar that inherits from QToolBar. I have a list of tuples (widget, callback) that contain what should be added to the toolbar. In theory, I want to group them by the requesting object and separate the…
GretaVan
  • 11
  • 1
1
vote
1 answer

qt qtoolbutton icon blurry

I have a problem where the icons used on QToolButtons on the QMenu attached to the QToolButton appear blurry. I have tried different sizes 24x24, 32x32, 64x64, different formats like png and svg but it always looks strange. On the image you can see…
Damir Porobic
  • 681
  • 1
  • 8
  • 21
1
vote
2 answers

QToolButton Space Between Text and Icon

I have a QToolButton. I wanted text and icon to be on it. I set button style by setToolButtonStyle(Qt::ToolButtonTextBesideIcon). But icon and text are so close to each other. Is there a method to give some space between icon and text by css?
mehmetfa
  • 199
  • 3
  • 15
1
vote
2 answers

Capture actions from checkable combobox

Inspired by the following thread: PyQt: How to set Combobox Items be Checkable? I was able to create a simple checkable "combobox" by using a QToolButton and adding checkable items to it using addAction. See simple code example: from PyQt4 import…
emblixt
  • 13
  • 4
1
vote
1 answer

How to set text below the QToolButton in QT not below the icon

I'm using QToolButton and I set the icon. Now I want Text "below the QToolButton", "Not below the icon". Is there any way to achieve this in C++,QT in Linux ?
Jyo the Whiff
  • 829
  • 9
  • 23
1
vote
0 answers

Applying a Qt style sheet to a QPushButton and a QToolButton

I'm trying to create a widget which will have similar behaviour to a QComboBox, but with different behaviours depending on whether the user clicks on the arrow or elsewhere on the widget. For starters, I'm modelling the widget itself as a wide…
Eos Pengwern
  • 1,467
  • 3
  • 20
  • 37
1
vote
2 answers

Fix QToolButton icon

I have QToolButton with a couple QActions inside it. The problem is that I've set an icon for this toolbar button and I don't want it to change, when I'm selecting some QAction (it changes set item to the text from selected QAction) from popup…
tema
  • 1,115
  • 14
  • 33