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. How to nest QWidget in QML?
Forum Updated to NodeBB v4.3 + New Features

How to nest QWidget in QML?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 6 Posters 736 Views 2 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.
  • A Offline
    A Offline
    abollo2
    wrote on last edited by
    #1

    I now need to nest a player window in QML, but the player window is developed using QWidget.

    I found a way, but I can't handle the QML level problem, the player window will always be blocked on the QML interface.

    QQmlApplicationEngine engine;
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    engine.load(url);
    
    QObject *qmlObj = engine.rootObjects().first();
    QWindow *qmlWindow = qobject_cast<QWindow *>(qmlObj);
    
    QWidget *fm = new QWidget();
    fm->winId();
    fm->setAttribute(Qt::WA_NativeWindow);
    fm->windowHandle()->setParent(qmlWindow);
    fm->move(40, 40);
    fm->show();
    

    How can I nest QWidget into QML, just like QML Item.

    please help me.

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

      This is not possible. No QWidgets inside the qml.

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

      1 Reply Last reply
      3
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        Hi
        This might be interesting
        https://www.kdab.com/declarative-widgets/
        But else @dheerendra is right and its really not natively supported.

        1 Reply Last reply
        3
        • K Offline
          K Offline
          kate.he
          wrote on last edited by
          #4

          We allways need QWidget in QML, does anyone else has some ideas?
          Thanks for help.

          J.HilkJ 1 Reply Last reply
          -1
          • K kate.he

            We allways need QWidget in QML, does anyone else has some ideas?
            Thanks for help.

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

            @kate-he You can always go the other way, and make your application a QWidget application and load Qml stuff via QQuickView and/or QQuickWidgets


            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
            1
            • K Offline
              K Offline
              kate.he
              wrote on last edited by
              #6

              @J-Hilk Thanks for ur ideas and We've thought about that before.
              If we do what you say, that means we need to refactor our exsiting project.
              That would be a huge job, which can't be done in a very short time.

              Are there any paid services in QT official, that can be customized for us to make QWidget embedded in QML possible?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @kate-he Hi,

                As @mrjj already pointed, KDAB's Declarative Widgets are the way to go.

                They are one of the biggest Qt consulting company so if you need support for that part, you should contact them.

                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
                3

                • Login

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