Hi Israel,

Try installEventFilter on the menu to see the KeyPress events before they are handled by the menu.

Regards, Tony


On 11/10/2018 7:07 AM, Israel Brewster wrote:
I want to modify a QAction if the user holds down a specific key. You can see similar behavior on the Mac, for example, if you pull down the Apple menu and press/release the option key - "About This Mac" changes to "System Information...", among other things. This is the behavior I want to emulate in my application.

To that end, I tried overriding the keyPressEvent on both the QMenuBar and the QMenu containing the QAction. However, my debugging indicated that neither of these keyPressEvent functions were called when pressing any key with the relevant QMenu displayed.

I'm sort of wondering if this is perhaps due to the event being handled at a lower level in order to provide "type ahead" type functionality in the menu? I did notice that different menu entries are selected when typing various keys, which I believe to be normal behavior.

Regardless, how can I respond to a keyPress type event in a QMenuBar or QMenu?

-----------------------------------------------
Israel Brewster




_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to