Qt World Summit: Submit your Presentation


Qt Quick applications do not repaint on window resize



  • As shown below, I'm having an issue where Qt applications do not continue rendering once the window is resized. Dragging the window larger shows white in the newly exposed space, and dragging it smaller than the initial size overwrites that area with white.

    alt text

    This is an example application created using the "Qt Quick Application - Empty" template in Qt Creator. The problem also happens with three other Qt Quick applications I develop, but does not happen for a legacy Widgets application. All other non-QT applications can be resized without issue.

    Multiple other computers I have tried do not have this problem. The only computer that has the problem is a 2017 iMac running Windows 10 Pro through Boot Camp. The issue arose after I reinstalled Windows 10 Pro; before the reinstallation, the computer was running Windows 10 Enterprise and had no problem resizing these applications.

    Though the application appears to freeze once the window has been resized, it continues running in the background. I can press keyboard shortcuts and see the expected messages log to the debug console.

    I realize the problem is with this particular computer, not the Qt application itself. But I haven't been able to find anything like this online and it only happens with Qt applications, so I'm asking here in case anyone has run into this before.

    I have provided the example application's code below just for completeness.

    Qt Creator 4.15.1
    Built with Qt 5.15.1

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    
    int main(int argc, char *argv[])
    {
    #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    #endif
    
        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();
    }
    

    main.qml

    import QtQuick 2.15
    import QtQuick.Window 2.15
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
    
        color: "#000"
    
        Rectangle {
            width: 50
            height: 50
            anchors.left: parent.left
            anchors.top: parent.top
            color: "#f00"
        }
    
        Rectangle {
            width: 50
            height: 50
            anchors.right: parent.right
            anchors.top: parent.top
            color: "#0f0"
        }
    
        Rectangle {
            width: 50
            height: 50
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            color: "#00f"
        }
    
        Rectangle {
            width: 50
            height: 50
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            color: "#ff0"
        }
    }