[Interest] Capture keyPressEvent on QMenuBar/QMenu?
Tony Rietwyk
tony at rightsoft.com.au
Thu Oct 11 02:02:53 CEST 2018
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 at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181011/9dc4ba65/attachment.html>
More information about the Interest
mailing list