Show text on QToolButton instead of icon?
-
wrote on 4 Aug 2020, 23:40 last edited by
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.
@JoeCFD what if you use the Qt version from the distribution ?
-
wrote on 26 Feb 2023, 04:02 last edited by JoeCFD
@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.
-
@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.