PDA

View Full Version : Grabbing mouse events from frame of top-level widget



mcb
20th June 2009, 00:38
I want to control the positioning of my top-level widget on the desktop. I have not yet found a way to intercept the mouse events as I reposition the widget by dragging on the frame. I thought I might be able to use QFocusFrame to define a region larger than my widget to give me access to the mouse events, but so far I have been unsuccessful. I am able to get the behavior I want with a non top-level widget, but this requires that I implement all the window frame decorations (close, maximize, minimize, etc).

Any suggestions or helpful links appreciated.

wysota
20th June 2009, 01:37
See QWidget::moveEvent().

mcb
21st June 2009, 06:04
The documentation for QMoveEvent reads:

The QMoveEvent class contains event parameters for move events.

Move events are sent to widgets that have been moved to a new position relative to their parent.

The event handler QWidget::moveEvent() receives move events.

My toy code suggests that a top-level widget never gets this event since there is no parent, and therefore, no relative position w.r.t. parent. Is this interpretation mistaken? Thanks.

I revisited my code and found a simple error. I do in fact get the move events. Thanks.