Question

How would you suggest to add a label on a QToolbar ? Since it only accepts action or somethings like that.

Thx

Was it helpful?

Solution

The QToolBar also accepts widgets like a QLabel through the method QToolBar::addWidget.

OTHER TIPS

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 );

You just pass the string to addAction method.

http://doc.qt.io/qt-5/qtoolbar.html

QAction *   addAction ( const QString & text )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top