How to constrain window movement?
-
Well, thinking better about your post, I guess that moveEvent is not useful in your case.
So you should try to catch the click and follow the mouse movement correcting the geometry along the drag. That's an idea, I've never experienced it.
T.
-
Good idea but there are no mouseMoveEvents on a window while it is being dragged.
-
what about QWidget::dragMoveEvent(QDragMoveEvent *event)?
-
you can use setFixedHeight( int ) in this way your widget can't expand on vertically and will have a fixed height, if you want that your widget to be fixed over a certain height you can use setMaximumHeight
-
Thanks for the tips.
dragMoveEvent() is meant for drag&drop, e.g. when dragging a file from one window to another. It is not for dragging windows itself.
The widget height is not the issue for me, it is its movement, so fixing the height wouldn't help much.
I am now looking at putting the widget into an QMdiArea to see if I can get the desired effect this way.
-
bq.
dragMoveEvent() is meant for drag&drop, e.g. when dragging a file from one window to another. It is not for dragging windows itself.dragMoveEvent() can be used while dragging widgets too. Have you seen the Draggable Icons demo that ships with Qt?
-
Maybe I should have been more explicit. The widget is a window which is either being moved by dragging the window frame handle (i.e. the window decoration) or by pressing Alt+LMB and dragging the window (this application is running under Gnome).
I just tested it but for neither of the two cases I get any dragMoveEvents, not on the window itself nor on the widget I am dragging it across. -
This "faq":http://developer.qt.nokia.com/faq/answer/how_can_i_handle_events_in_the_titlebar_and_change_its_color_etc might be of interest to you ...
-
Thanks for the pointer.
In my particular case I solved it using an MDI area and intercepting mouse events on it through eventFilter(). That way I was able to rewrite the events to maintain the same X value before they are sent to the actual movement handler.
-
glad to hear that.
could you also create a new wiki page and add your code snip? will help other developers :) -
I'd like to but my employer would not like it at all, even if it was abstract code, so unfortunately I can't say more than I have.