Is there a simple way to drag on anywhere in the window to move it?
-
-
I want to make a window moving when I drag anywhere in the window's viewport, just as I drag the title bar of the window.
Is it the only way to do this by reimplementing themouse*Event
?@Sauntor said in Is there a simple way to drag on anywhere in the window to move it?:
I want to make a window moving when I drag anywhere in the window's viewport
Window ≠ Widget.
So what do you want to do exactly?
Depending on the use case, the UX can be awful then, because you cant click somewhere without moving the whole thing around. -
@Sauntor said in Is there a simple way to drag on anywhere in the window to move it?:
I want to make a window moving when I drag anywhere in the window's viewport
Window ≠ Widget.
So what do you want to do exactly?
Depending on the use case, the UX can be awful then, because you cant click somewhere without moving the whole thing around. -
I want to make a window moving when I drag anywhere in the window's viewport, just as I drag the title bar of the window.
Is it the only way to do this by reimplementing themouse*Event
?@Sauntor said in Is there a simple way to drag on anywhere in the window to move it?:
Is it the only way to do this by reimplementing the mouse*Event ?
Yes,
you need to memorize the mouse location in mousePressEvent
and in mouseMoveEvent to move the window with the delta value between the actual mouse location and the memorized location,
then finaly to update the memorized location with the new mouse location. -
@Sauntor said in Is there a simple way to drag on anywhere in the window to move it?:
Is it the only way to do this by reimplementing the mouse*Event ?
Yes,
you need to memorize the mouse location in mousePressEvent
and in mouseMoveEvent to move the window with the delta value between the actual mouse location and the memorized location,
then finaly to update the memorized location with the new mouse location. -
-
On Linux there are window managers that allow to drag any window by holding down the Alt key. In that specific case you wouldn't have to do anything yourself.
As a general case I would think about using
installEventFilter()
to write an event filter that can be applied to any widget. The complicated part is that if you have a dialog with labels if you click on a label the dialog will not get the mouse events. Instead the label would need to handle this instead (i.e. all the labels and buttons, etc. inside the dialog). Maybe someone has an idea how to intercept mouse events actually meant for a widget's children in Qt. (With the event filter you could at least apply it to every widget you place inside the dialog.) -
On Linux there are window managers that allow to drag any window by holding down the Alt key. In that specific case you wouldn't have to do anything yourself.
As a general case I would think about using
installEventFilter()
to write an event filter that can be applied to any widget. The complicated part is that if you have a dialog with labels if you click on a label the dialog will not get the mouse events. Instead the label would need to handle this instead (i.e. all the labels and buttons, etc. inside the dialog). Maybe someone has an idea how to intercept mouse events actually meant for a widget's children in Qt. (With the event filter you could at least apply it to every widget you place inside the dialog.)@SimonSchroeder Thanks😘
-
-