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. Qml in qt widgets
Forum Updated to NodeBB v4.3 + New Features

Qml in qt widgets

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 4 Posters 3.3k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Invalid qml file path ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kaluss
      wrote on last edited by
      #3

      No, because when it was wrong Qt Creator said me that in output...

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #4

        I just created new QtUI application project and did the following. It works perfectly.

        What is 'this' object in your case ? It is QMainWIndow or QWidget ?

        @QWidget *wid = new QWidget;
        QPushButton *butt = new QPushButton("pthinks.com");
        QVBoxLayout *lyt = new QVBoxLayout(wid);
        lyt->addWidget(butt);
        QQuickView *view = new QQuickView();
        QWidget *container = QWidget::createWindowContainer(view, this);
        container->setMinimumSize(200, 200);
        container->setMaximumSize(200, 200);
        container->setFocusPolicy(Qt::TabFocus);
        view->setSource(QUrl("main.qml"));
        lyt->addWidget(container);
        wid->show();@

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kaluss
          wrote on last edited by
          #5

          QDialog

          1 Reply Last reply
          0
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Qt Champions 2022
            wrote on last edited by
            #6

            I have replaced QWidget *wid = new QWidget;
            with
            QDialog *wid = new QDialog;

            in above code snippet. It works perfectly. When you launch your program, what is shown ? Is the dialog shown ? Only QML Window is missing ?

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kaluss
              wrote on last edited by
              #7

              The content of qml is not displayed.
              It's look like the place for it is prepared.

              //code of qml file

              import QtQuick 2.1
              import QtQuick.Controls 1.0
              import QtQuick.Window 2.0

              Rectangle {
              id: recMain
              height : 100
              width : 100
              Button
              {
              text:"hoho"
              }

              AnimatedImage {
                  id                       : buttonImage
                  source                   : "gfx/loading.png"
                  anchors.horizontalCenter : recMain.horizontalCenter
                  anchors.verticalCenter   : recMain.verticalCenter
              
                  NumberAnimation on rotation {
                      from     : 0; to : 360; running : buttonImage.visible = true; loops : Animation.Infinite;
                      duration : 1000;
                  }
              }
              

              }

              //the end of code of qml file

              I put the button to se if maybe only png file is not loaded.

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #8

                Hi,

                See if you get any errors using "errors":http://qt-project.org/doc/qt-5/qquickview.html#errors function.

                157

                1 Reply Last reply
                0
                • dheerendraD Offline
                  dheerendraD Offline
                  dheerendra
                  Qt Champions 2022
                  wrote on last edited by
                  #9

                  It must be issue with QML file only. Either it is path issue with QML file itself or image file issue. Hope you are able to run the QML file directly. You can try adding QMLFile and ImageFile in Resource file and refer it. It may solve your issue.

                  Dheerendra
                  @Community Service
                  Certified Qt Specialist
                  http://www.pthinks.com

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    Kaluss
                    wrote on last edited by
                    #10

                    Ok, I will check it, but later becuase Im on my job now :P

                    Thanks all for help. Will write when I check all possibilities

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Kaluss
                      wrote on last edited by
                      #11

                      Hi,
                      I already know where was the problem.
                      I didn't set size of container and thus of that there was no place to display qml object.

                      Strange, because it's hard to set ( probably for me :) ) right size policy between qml object and container widget.

                      If someone have some good examples where qml objects are combined with Qt widgets I will be thankful.

                      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