Unsolved QQuickWidget problem
-
Hello, I am working on a desktop application using qml. Given that qml does not have docks I am testing using a Widget based aplication with multiple QDockWidget, each one loading a QQuickWidget to use the qml files.
However I have noticed that several times the qml elements either freeze, stop working or paint wrong elements, though not all at once and sometimes that can be fixed by undocking the docks. I want to know if there is a way to solve this issue or if it is a limitation of using qquickwidget that way. Thanks. -
Hmm, works for me so far. Any idea how to reproduce this?
main.cpp
#include <QApplication> #include <QMainWindow> #include <QDockWidget> #include <QQuickWidget> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); QMainWindow mainWindow; { auto centalWidget = new QWidget(&mainWindow); mainWindow.setCentralWidget(centalWidget); } { auto dockWidget = new QDockWidget("One", &mainWindow); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); auto view = new QQuickWidget(dockWidget); view->setResizeMode(QQuickWidget::SizeRootObjectToView); dockWidget->setWidget(view); view->setSource(QUrl("qrc:/main1.qml")); mainWindow.addDockWidget(Qt::LeftDockWidgetArea, dockWidget); } { auto dockWidget = new QDockWidget("Two", &mainWindow); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); auto view = new QQuickWidget(dockWidget); view->setResizeMode(QQuickWidget::SizeRootObjectToView); dockWidget->setWidget(view); view->setSource(QUrl("qrc:/main2.qml")); mainWindow.addDockWidget(Qt::RightDockWidgetArea, dockWidget); } mainWindow.showMaximized(); return app.exec(); }
main1.qml
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 Rectangle { id: main color: "orange" Text { anchors.horizontalCenter: parent.horizontalCenter text: "one" SequentialAnimation on font.pixelSize { loops: Animation.Infinite PropertyAnimation { to: 200 } PropertyAnimation { to: 0 } } SequentialAnimation on y { loops: Animation.Infinite PropertyAnimation { duration: 1000; to: 1000 } PropertyAnimation { duration: 1000; to: 0 } } } }
main2.qml
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 Rectangle { color: "pink" Text { anchors.centerIn: parent text: "two" SequentialAnimation on font.pixelSize { loops: Animation.Infinite PropertyAnimation { to: 200 } PropertyAnimation { to: 0 } } SequentialAnimation on rotation { loops: Animation.Infinite PropertyAnimation { duration: 1000; to: 360 } PropertyAnimation { duration: 1000; to: 0 } } } }
-
Thanks for the reply, it seems like with independent simple qml elements that does not happen.
While testing your example with custom qml I am having some problems:- Sometimes it crashes when changing dock positions
- if I add a Canvas element in the qml it disappears when docking/undocking
- Canvas3d elements shaders don't compile
Maybe I am having this issues because I am using a common model (derived from QAbstractItemModel) to update the qml elements (all of them). I will check it and try to describe more clearly what my situation is.
By the way I am testing with qt 5.5 and 5.6