Changing the width of the window when moving it to another monitor leads to multiple switching between monitors on Windows.
Unsolved
General and Desktop
-
This happans, when one half of the app window is on the first monitor and the other on the second (first screenChanged signal).
Qt version 5.12
OS WindowsFirst(app startup) monitor resolution: 2560 x 1440
Second monitor resolution: 1920 x 1080Minimal example:
main.qmlimport QtQuick 2.12 import QtQuick.Window 2.12 Window { id: root visible: true width: 300 height: 300 onScreenChanged: { root.width = (root.width == 300 ? root.width / 2 : 300) } }
main.cpp:
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); }
App output:
setGeometry: Unable to set geometry 300x600+2268+468 on QQuickWindowQmlImpl/''. Resulting geometry: 600x600+2268+468 (frame: 11, 45, 11, 11, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215). setGeometry: Unable to set geometry 600x600+2268+468 on QQuickWindowQmlImpl/''. Resulting geometry: 300x600+2268+468 (frame: 11, 45, 11, 11, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215). setGeometry: Unable to set geometry 600x600+2268+468 on QQuickWindowQmlImpl/''. Resulting geometry: 300x600+2268+468 (frame: 11, 45, 11, 11, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215). ...