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. Placing QML window over Qt dialog

Placing QML window over Qt dialog

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 1.8k 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.
  • G Offline
    G Offline
    gabor53
    wrote on last edited by
    #1

    Hi,
    I created a busy indicator in qml and want to place it over a dialog. Currently this is what I have:
    under qml.qrc Busy.qml (and BusyForm.ui):

    import QtQuick 2.6
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        width: 100
        height: 100
        modality: Qt.ApplicationModal
    flags: Qt.FramelessWindowHint
    
        BusyForm {
            Image {
                id: container
    
                source: "images/busy.png";
    
                NumberAnimation on rotation {
                    running: container.visible
                    from: 0; to: 360;
                    loops: Animation.Infinite;
                    duration: 1200
                }
        }
    }
    }
    
    

    In main.cpp:

    #include "mainwindow.h"
    #include "ui_display.h"
    #include <QApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char* argv[]) {
      QApplication a(argc, argv);
    
      MainWindow w;
    
      QQmlApplicationEngine engine;
      engine.load(QUrl(QStringLiteral("qrc:/Busy.qml")));
      if (engine.rootObjects().isEmpty())
        return -1;
      w.show();
    
      return a.exec();
    }
    
    

    The project builds without error. How can I call Busy.qml from a dialog so the busy widget would appear above the dialog?
    Thank you.

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

      You would like to place the your busy.qml over object 'w' ? Object 'w' is an instance MainWindow. Is the MainWindow inherited from QMainWindow/QWidget ? if yes, this means that you are mixing Qt widget and QML. Please look at this topic.

      Also you should create component & object from Busy.qml using Qt.createComponen & createObject. After that you should be able do this.

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

      G 1 Reply Last reply
      0
      • dheerendraD dheerendra

        You would like to place the your busy.qml over object 'w' ? Object 'w' is an instance MainWindow. Is the MainWindow inherited from QMainWindow/QWidget ? if yes, this means that you are mixing Qt widget and QML. Please look at this topic.

        Also you should create component & object from Busy.qml using Qt.createComponen & createObject. After that you should be able do this.

        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #3

        @dheerendra
        There is an other dialog over which I would like to place the qml.

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

          what is that 'other dialog' means ?. Is it QML component or QWidget based dialog ?

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

          G 1 Reply Last reply
          0
          • dheerendraD dheerendra

            what is that 'other dialog' means ?. Is it QML component or QWidget based dialog ?

            G Offline
            G Offline
            gabor53
            wrote on last edited by
            #5

            @dheerendra
            Hi,
            It is a QWidget based dialog.

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

              You can embed the QML Window inside the QWIdget based UI. Hope you have looked createWindowContainer function of QWidget.

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

              1 Reply Last reply
              2
              • G Offline
                G Offline
                gabor53
                wrote on last edited by
                #7

                Thank you.

                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