Qt-interest Archive, July 2002
alt key press twice? bug?
Message 1 in thread
hello,
i have an application that contains an opengl widget. the opengl widget
reimplements the keyPressEvent/ReleaseEvent functions.
the opengl widget grabs focus whenever the mouse moves inside it:
void
GLAnim::mouseMoveEvent( QMouseEvent ... )
{
...
if ( !hasFocus() )
setFocus();
...
}
when modifier buttons are pushed ( Alt, Alt+Shift, Ctrl, Ctrl+Shift ), the
cursor changes to a customized cursor.
this is the basic premise. now, for some reason, when i press and release
alt numerous times, keyPressEvent is called only every other press. is
there a reason for this?
put another way:
keyboard action function call
-------------------------------------
alt pressed keyPressEvent called
alt release keyReleaseEvent called
alt pressed
alt release keyReleaseEvent called
alt pressed keyPressEvent called
alt release keyReleaseEvent called
alt pressed
alt release keyReleaseEvent called
...
other bizarre things happen, too, if i, for example, press both alt keys
down together, then release one at a time
jon
Message 2 in thread
Quoth Jonathan Lee (on 02/07/10) :
> hello,
>
> i have an application that contains an opengl widget. the opengl widget
> reimplements the keyPressEvent/ReleaseEvent functions.
>
> when modifier buttons are pushed ( Alt, Alt+Shift, Ctrl, Ctrl+Shift ), the
> cursor changes to a customized cursor.
>
> this is the basic premise. now, for some reason, when i press and release
> alt numerous times, keyPressEvent is called only every other press. is
> there a reason for this?
I have experienced similar problems, and eventually tracked it down to
the menu bar. What's happening is that there's a Windows standard that
allows you to navigate the menu bar using the arrow keys, which is activated
by pressing/releasing the Alt key. You may notice that the menubar actually
gains keyboard focus.
There's no easy way around this; I ended up having to override the
eventFilter method in my class which inherits from QMenuBar, then make
myself private friends with QMenuBar in order to access some private
methods. Very ugly and very horrible, but it does work...
Perhaps the Trolls will be kind enough one day to provide a method on QMenuBar
to disable the Alt stealing functionality.
Cheers,
Anthony
Maptek Adelaide
Anthony Gibbs -- Software Engineer
Email: Anthony.Gibbs@maptek.com.au Phone: +61 8 8338 9225
Dale Cooper: [speaking into tape recorder] Diane, I'm
holding in my hands a small box of chocolate bunnies