Update QAction and QToolButton
Solved
General and Desktop
-
Hello !
I have in my
QMenu
an action, and a tool button in myQToolBar
linked to this action.
But I wanted the button in the toolbar to have a shorter text than the action in the menu:m_runTestsAction = testsMenu->addAction(runIcon, tr("Run tests")); m_runTestsAction->setEnabled(false); m_runTestsButton = new QToolButton; m_runTestsButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_runTestsButton->setDefaultAction(menuBar->getRunTestsAction()); m_runTestsButton->setText(tr("Run"));
Problem: each time I update the enable state of the action (to update both menu and toolbar), it puts back the full text under the button
Run tests
.Is it possible to update a field in the action and trigger only the same change on the tool button?
Thanks!
-
The button's icon text is taken from QActions iconText() property. So set the iconText to 'Run'.
-
@Christian-Ehrlicher Thanks a lot, it is exactly what I was missing!