Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QAction still triggered by keyboard shortcut when disabled.



  • Hello!

    In qt-5.11.0 it looks like a disabled QAction will still be triggered by typing its keyboard shortcut. The docs say otherwise.

    Any thoughts on this? I am using the main menu for QMainWindow on macOS.

    Thanks!



  • @patrickkidd

    Probably you need to show the code snippet on the section disabling the keyboard shortcut.

    Also did you rerun qmake and a rebuild?



  • @koahnig Yes, I have cleaned the project for sure.

        allActionsEnabled = self.activeLicense() is not None
        actions = \
            self.ui.menuFile.findChildren(QAction) + \
            self.ui.menuEdit.findChildren(QAction) + \
            self.ui.menuView.findChildren(QAction) + \
            self.ui.menuInsert.findChildren(QAction)
        for action in actions:
            if action != self.ui.actionQuit:
                action.setEnabled(allActionsEnabled)

Log in to reply