Show text on QToolButton instead of icon?
-
I have a
QAction
with checkable, icon and text all set. And then I assigned it to the menu and aQToolButton
. It looks fine on the menu with icon and text showing side by side. However for the QToolButton, I want to set a shorter text and show it instead of the icon and text from the QAction.pMenu->addAction(m_pActionShowMyDialog); m_ui->myDialogButton->setDefaultAction(m_pActionShowMyDialog); m_ui->myDialogButton->setText("MD");
I tried to setText on the button after setting the QAction but it still shows the icon.
-
Hi,
You can use QToolButton::setToolButtonStyle.
-
You can use the QAction::iconText property.
-
@JoeCFD what if you use the Qt version from the distribution ?
-
@SGaist Qt 5.15.3 is the one in the distribution of Ubuntu 22.04 and QToolButton with flag Qt::ToolButtonTextOnly still shows the icon. I solved the issue by setting an empty icon for this flag. Before, I did not need to.
-
@JoeCFD from the looks of it, it could be an Ubuntu specific bug.