How can I get a borderless child window to re-scale to current screen in multi-monitor setup?

So as far as I understand, your current goal is to move the window via the WIN-API. You will have to do so via C++. The approach would be:

  1. Pass the QML Window to a C++-Method exposed to QML as a QQuickWindow (The QML window instanciates that type, as seen in the documentation)
  2. Use QWindow::winId to get the native HWND
  3. Call the SetWindowPos WIN-API method to move it

Code sample (C++-part):

// the method
void moveWindow(QQuickWindow *window, int x, int y) {
    HWND handle = (HWND)window->winId();
    Q_ASSERT(handle);
    ::SetWindowPos(handle, HWND_TOP,
                   x, y, 0, 0,
                   SWP_NOSIZE | SWP_NOZORDER);
}

// assuming "moveWindow" is a member of "MyClass"
qmlEngine->rootContext()->setContextProperty("mover", new MyClass(qmlEngine));

Code sample (QML-part):

// call this method as soon as the drag has finished, with the new positions
mover.moveWindow(idOfWindow, xPos, yPos);

Note: I would recommend you try out calling this only after the drag was finished (and move the window as you do right now until then). If that works, you can try out what happens if you call this during the drag instead of changing the x/y of the window.

Tags:

Windows

Qt

Qml