Ponzifex
Ponzifex

Reputation: 590

QQuickView window freezes upon mouse resize

I have problem resizing the window using this example. It works, but unpredictable when it becomes unresponsive. Window minimization and maximization works every time, but resizing with the mouse causes weird, frozen behavior. Happens on Windows 10 using Qt 5.12.0. What I do wrong here? Thanks!

#include <QGuiApplication>
#include <QQuickView>
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QQuickView view;
    view.setSource(QUrl(QStringLiteral("qrc:/main.qml")));
    view.show();
    return app.exec();
}

And this is the main QML code:

import QtQuick 2.10
Rectangle {
    anchors.fill: parent
    color: "red"
}

Upvotes: 0

Views: 420

Answers (1)

Ponzifex
Ponzifex

Reputation: 590

Ok, I have figured out the solution:

anchors.fill: parent should not be used in the root element, but instead we have to tell to the view in C++ the following:

view.setResizeMode(QQuickView::SizeRootObjectToView);

Upvotes: 1

Related Questions