Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QQuickWidget problem
Qt 6.11 is out! See what's new in the release blog

QQuickWidget problem

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 2.0k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    PhlipVR
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      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 }
              }
          }
      }
      
      1 Reply Last reply
      2
      • P Offline
        P Offline
        PhlipVR
        wrote on last edited by PhlipVR
        #3

        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

        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