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

how to Integrat QML in QWidget App ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 3 Posters 3.1k 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
    Alex_wang
    wrote on last edited by
    #1

    I am new to Qt and QML,so please in detail :

    1. QQuickView
      2.QQuickWidget
    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @Alex_wang
      The docs are quite self-explanatory (QQuickView and QQuickWidget.
      QQuickView is used to load a QML scene given a URL whereas QQuickWidget also does the same but it can be embedded into existing QWidget. So if you want a mixture of QWidgets and QtQuick use QQuickWidget.

      157

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

        Hi
        Maybe this book
        https://qmlbook.github.io/
        would be great to browse first before coding.

        1 Reply Last reply
        3
        • A Offline
          A Offline
          Alex_wang
          wrote on last edited by
          #4

          I want to render YUV video with QOpenglWidget,and render a control UI via QML that will display upon the video.
          But the control UI should be translucent so that we can see the video under it.

          If I use the QQuickWidget, have to the control UI translucent by the step:

          QQuickWidget *view = new QQuickWidget(this);//this->QOpenglWidget
          view->setAttribute(Qt::WA_AlwaysStackOnTop, true);
          view->setClearColor(QColor(Qt::transparent));
          

          this is valid, but I find a Transparent stripe inside the control UI.
          anyone ideas ?

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

            @Alex_wang

            This limitation only applies when there are other widgets underneath the QQuickWidget inside the same window. Making the window semi-transparent, with other applications and the desktop visible in the background, is done in the traditional way: Set Qt::WA_TranslucentBackground on the top-level window, request an alpha channel, and change the Qt Quick Scenegraph's clear color to Qt::transparent via setClearColor().

            Not sure but can you try setting Qt::WA_TranslucentBackground (using setAttribute) as well as alpha channel using setFormat (QSurfaceFormat) ?

            157

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Alex_wang
              wrote on last edited by
              #6

              I have tried,butt it is still failing!

              QQuickWidget *view = new QQuickWidget(this);//this->QOpenglWidget
              view->setAttribute(Qt::WA_AlwaysStackOnTop, true);
              view->setClearColor(QColor(Qt::transparent));
              view->setAttribute(Qt::WA_TranslucentBackground);
              view->setSource(QUrl("qrc:/main.qml"));
              view->show();
              

              main.qml:

              Item
              {
                     opacity: 0.8
              }
              

              I find that when I do not set opacity to 0.8 in QML , the control UI is not transparent;
              but when I set opacity to 0.8 in QML, the control UI is slight transparent ,
              and the error with a transparent stripe appears.

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

                @Alex_wang Can you also try to setFormat with alpha channel for QQuickWidget? Smthing like:

                QSurfaceFormat format;
                format.setAlphaBufferSize(8);
                

                157

                1 Reply Last reply
                2
                • A Offline
                  A Offline
                  Alex_wang
                  wrote on last edited by
                  #8
                  QQuickWidget *view = new QQuickWidget(this);//this->QOpenglWidget
                  QSurfaceFormat format;
                      format.setAlphaBufferSize(8);
                      format.setDepthBufferSize(32);
                      view->setFormat(format);
                  view->setAttribute(Qt::WA_AlwaysStackOnTop, true);
                  view->setClearColor(QColor(Qt::transparent));
                  view->setAttribute(Qt::WA_TranslucentBackground);
                  view->setSource(QUrl("qrc:/main.qml"));
                  view->show();
                  

                  It is no effect! ..............when I not set opacity to 0.8 in QML

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

                    @Alex_wang Hmm, as the docs says there are some limitations to it. There are ways which we tried but it still doesn't work. I would suggest to ask this question to mailing list.

                    157

                    1 Reply Last reply
                    1

                    • Login

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