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. How to add qml to mainwindow ui file
QtWS25 Last Chance

How to add qml to mainwindow ui file

Scheduled Pinned Locked Moved Unsolved General and Desktop
qquickwidgetmainwindow
4 Posts 3 Posters 2.4k 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.
  • M Offline
    M Offline
    milan
    wrote on last edited by milan
    #1

    Can somebody help me how to add qml to mainwindow ui. I added a QQuickwidget in mainwindow.ui from designer.

    Then I added following code:

        QQuickView *qmlView = new QQuickView();
        qmlView->setSource(QUrl::fromLocalFile("test.qml"));
        ui->widget->createWindowContainer(qmlView, this);
    
    

    But I can see nothing when I run the program inside QQuickWidget.

    J.HilkJ 1 Reply Last reply
    0
    • T Offline
      T Offline
      TobbY
      wrote on last edited by
      #2

      Hello,
      Pls refer this thread for brief idea about QML integration to widgets.

      M 1 Reply Last reply
      0
      • T TobbY

        Hello,
        Pls refer this thread for brief idea about QML integration to widgets.

        M Offline
        M Offline
        milan
        wrote on last edited by
        #3

        @TobbY . Thanks, I tried this code, but it does not show anything on QML too.

        1 Reply Last reply
        0
        • M milan

          Can somebody help me how to add qml to mainwindow ui. I added a QQuickwidget in mainwindow.ui from designer.

          Then I added following code:

              QQuickView *qmlView = new QQuickView();
              qmlView->setSource(QUrl::fromLocalFile("test.qml"));
              ui->widget->createWindowContainer(qmlView, this);
          
          

          But I can see nothing when I run the program inside QQuickWidget.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @milan said in How to add qml to mainwindow ui file:

          Can somebody help me how to add qml to mainwindow ui. I added a QQuickwidget in mainwindow.ui from designer.

          Then I added following code:

              QQuickView *qmlView = new QQuickView();
              qmlView->setSource(QUrl::fromLocalFile("test.qml"));
              ui->widget->createWindowContainer(qmlView, this);
          
          

          If you added a QQuickWidget via designer, why adding anoher QQuickView via code!?

          just access your QuickWidget and set the source:

          ui->quickWidget->setSource(QUrl(QStringLiteral("qrc:/test.qml")));
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          2

          • Login

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