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 18 Sept 2018, 12:37 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 1 Reply Last reply 18 Sept 2018, 13:11
    0
    • T Offline
      T Offline
      TobbY
      wrote on 18 Sept 2018, 12:48 last edited by
      #2

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

      M 1 Reply Last reply 18 Sept 2018, 13:05
      0
      • T TobbY
        18 Sept 2018, 12:48

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

        M Offline
        M Offline
        milan
        wrote on 18 Sept 2018, 13:05 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
          18 Sept 2018, 12:37

          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 Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 18 Sept 2018, 13:11 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

          4/4

          18 Sept 2018, 13:11

          • Login

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