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.
-
Hi,
You can use QToolButton::setToolButtonStyle.
-
You can use the QAction::iconText property.
-
You can use the QAction::iconText property.
-
Hi,
You can use QToolButton::setToolButtonStyle.
-
@SGaist This does not work anymore with Qt 5.15.3 on Ubuntu 22.04. My tool button works fine on Ubuntu 18.04.
-
@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.