How would you suggest to add a label on a QToolbar ? Since it only accepts action or somethings like that.
Thx
How would you suggest to add a label on a QToolbar ? Since it only accepts action or somethings like that.
Thx
The QToolBar
also accepts widgets like a QLabel
through the method QToolBar::addWidget
.
As abresas wrote, a toolbar can be populated with a QAction. The QString passed along with the QAction is used in several ways (e.g as tooltip), but with 4.8 the default is to show a toolbar button with the icon only. To show the text with the icon, set the toolbar to a Qt::ToolButtonStyle, e.g.
ui->toolBar->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
The QToolBar
also accepts widgets like a QLabel
through the method QToolBar::addWidget
.
You just pass the string to addAction method.
http://doc.qt.io/qt-5/qtoolbar.html
QAction * addAction ( const QString & text )
© 2022 - 2024 — McMap. All rights reserved.
ui->mainToolBar->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
in Qt 5.4 – Topeka