PDA

View Full Version : Qt widget enter/leave event



bunjee
7th December 2007, 11:06
Hey there,

I'm using the latest Qt 4.4 snapshot.
I have a widgets with enter and leave event implementations.

When I get an enter event I'm highlighting the widget.

On some very specific cases the enter / leave event is not called.

For example when deleting a widget and the cursor goes directly inside the next one.

Is there a more reliable way to detect if the cursor is in or out the widget?

Thanks.

wysota
7th December 2007, 11:30
You can use QWidget::underMouse() to check if the cursor is inside a specific widget.

bunjee
7th December 2007, 12:06
Thanks,

I've done several tests.
It appears those Enter / Leave event are working fine on Qt 4.3.

In Qt 4.4 the enter / leave event seems different and doesn't work all the time.

Are you aware of some changes ? Because that issue is not new on the Qt snapshot.

wysota
7th December 2007, 12:36
Qt 4.4 is not stable yet, so you use it at your own risk.

bunjee
7th December 2007, 12:44
Do you know when the stable version is scheduled ? January ?

wysota
7th December 2007, 12:47
It'll be out in March.

Uwe
7th December 2007, 13:08
In Qt 4.4 the enter / leave event seems different and doesn't work all the time. Are you aware of some changes ? Because that issue is not new on the Qt snapshot.

Read http://labs.trolltech.com/blogs/2007/08/09/qt-invaded-by-aliens-the-end-of-all-flicker and you will understand, why it is very likely to find problems like these in 4.4 snapshots. If you have an important application it's probably a good idea to wait for 4.4.1.

Uwe

bunjee
7th December 2007, 13:30
Actually, that's the feature I need for my application to work.

I'm working on an application heavily based on widgets (to say the least :)).

But I'm not sure if there is a link with my enter/leave events issue.
And I'm not sure this is even a bug (since widgets are no longer the same in 4.4).

Uwe
7th December 2007, 14:30
Actually, that's the feature I need for my application to work. I'm working on an application heavily based on widgets (to say the least :)).
The article is about, that Qt 4.4 will reimplement functionalities of the underlying window system, because it can't control it enough to avoid flickering. How is this related to your application ?


But I'm not sure if there is a link with my enter/leave events issue.

"Moving away from native windows isn’t done over the night. Window handles have been in Qt from day one, and consequently our GUI kernel is heavily built around them. The main technical challenges in that respect have been core functionality such as mouse events, widget cursors, enter/leave events, drag’n'drop and so on. With native windows all widget events are related to a window handle and our job is simply to map system events into Qt events. Consequently, when we make our child widgets windowless, all events are related to the top-level window and we have to figure out ourselves which widget is the correct receiver for the given event."


And I'm not sure this is even a bug (since widgets are no longer the same in 4.4).
QWidgets will continue being QWidgets: they have to receive exactly the same events. Otherwise almost all applications will break.

Uwe

bunjee
8th December 2007, 06:20
With few exceptions you will get enter/leave events when the cursor
moves in/out of a widget. Exceptions are when there is:

1) a mouse grabber (QWidget::grabMouse is called).
2) a mouse button pressed.
3) a modal dialog.
4) an active popup.

The Qt::WA_UnderMouse attribute is set on the entered widget.

As I said, enter/leave events doesn't quite work how it's suppose to
work at the moment, but we will look into it.

--
Bjoern Erik Nilsen - bnilsen at trolltech.com
Trolltech ASA - Sandakervn. 116, P.O. Box 4332 Nydalen, 0402 Oslo, Norway

Here is the trolltech answer.

wysota
8th December 2007, 12:57
"The Qt::WA_UnderMouse attribute is set on the entered widget."

This is your case...

JandunCN
28th April 2014, 03:09
Have you find out what's the point?I encoutered the similar problem as you did.