I have a QToolButton with the style QToolButton::MenuButtonPopup so that it has a drop down arrow alongside the button which shows a menu when clicked.

I want to disable one of the actions in the menu when its shown depending on the state of the system. I can catch the click on the toolbutton itself by connecting the clicked() signal to a slot and disabling the action there. But how do I connect to the click on the arrow button?

Or is it better to make the action responsible for its state and listen to system changes?


my existing code is along the lines of
Qt Code:
  1. {
  2. ....
  3. myButton = new QToolButton(this);
  4. myButton->setPopupMode(QToolButton::MenuButtonPopup);
  5. connect(myButton, SIGNAL(clicked()), this, SLOT(slot_myButtonClicked()));
  6.  
  7. QMenu* myMenu = new QMenu(this);
  8. pMyAction = new MyAction(this);
  9. myMenu->addAction(pMyAction);
  10. ....
  11. }
  12.  
  13. void MainWindow::slot_myButtonClicked()
  14. {
  15. pMyAction->setEnabled(.....);
  16. myButton->showMenu();
  17. }
To copy to clipboard, switch view to plain text mode 




TIA

MrC