Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Changing the width of the window when moving it to another monitor leads to multiple switching between monitors on Windows.

Changing the width of the window when moving it to another monitor leads to multiple switching between monitors on Windows.

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 142 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chiffa
    wrote on last edited by
    #1

    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 Windows

    First(app startup) monitor resolution: 2560 x 1440
    Second monitor resolution: 1920 x 1080

    Minimal example:
    main.qml

    import 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).
    ...
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved