Question

I remember that in C# there is a method called DragMove() that allows to drag a window by clicking on the selected area.

Example (from this answer):

private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
    if (e.ChangedButton == MouseButton.Left)
        this.DragMove();
}

Is there any function like this in Qt world?

I know that a solution would be to listen for mousePressEvent and mouseMoveEvent but I just want to know if there is native method that would allow to drag the winodw on the screen just calling it, like in C# this.DragMove().

Also, it needs to be cross-platform...

Was it helpful?

Solution

No, there is no function like what you refer to in Qt. Listening for mouse events is simple, and would be considered idiomatic in Qt.

If you want the widget to be draggable by pressing anywhere between controls, just implement those events in the base event. Any area not covered by controls will be "draggable".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top