Do you have mouse tracking enabled on this widget? Otherwise you can't detect when the mouse enters the widget. I'm not sure that you implement it the proper way. Changing the mouse cursor when a modifier key (eg Ctrl) il pressed should not be done with the widget keyPressEvent, as this will not work if the user presses the key when the mouse is outside, then enters the widget. Also, keyPressEvent only works with focus, which is not what you want.
I would suggest capturing the key presses at an upper level (such as the MainWindow) and change the child widget mouse cursor accordingly with setCursor. This way, the behavior is independant from focus, does not require mouse tracking, and does not require the cursor to be over the widget when the key is pressed. Etienne 2014-04-04 16:20 GMT+02:00 Paul Miller <stel...@gmail.com>: > Here is another regression I found that is a show-stopper for us. > > In a custom widget I have a keyPressEvent() and keyReleaseEvent() > handler to update a cursor when modifier keys are pressed (such as Cmd). > In Qt 5.x, pressing Cmd (or shift, or ctrl) causes no keyPressEvents > UNTIL the user clicks on the widget. Manually calling setFocus() on the > widget when the mouse enters it doesn't help either. > > This all worked before 5.x. > > I can't be the only one to find this can I? > _______________________________________________ > 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