Label in a QToolbar

Matthieu Riegler picture Matthieu Riegler · Apr 9, 2012 · Viewed 9.4k times · Source

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

Thx

Answer

handle picture handle · Nov 30, 2012

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