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. Adding QQuickView(QWindow) to a QStackedWidget->addWidget(QWidget)
Forum Updated to NodeBB v4.3 + New Features

Adding QQuickView(QWindow) to a QStackedWidget->addWidget(QWidget)

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 6 Posters 8.6k 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.
  • N Offline
    N Offline
    nizeguy
    wrote on last edited by
    #1

    hi folks,

    I'm porting code to qt5. Now i came to this block:

    Q: how do i add a QQuickView to a QStackedWidget ? qStackedWidget->addWidget(QWidget *); BUT QQuickView is a QWindow, not a QWidget.

    Q: is it possible to add qqviews to tabs and stackedwidgets like it was possible in qt4.8 ?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      AFAIK, you have to fall back on QtQuick1 module. With QtQuick2, it may not be possible (I'm not 100% sure, though).

      (Z(:^

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nizeguy
        wrote on last edited by
        #3

        I want to deprecate QtQuick 1.

        It should be possible by design with QtQuick2.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          QtQuick2 uses entirely different graphics stack (OpenGL based SceneGraph) than QWidgets module and QtQuick1 (raster). You can post a question on development mailing list to be absolutely sure. I only use QML2 in a standalone QQuickView, so the issue has never arisen for me (yet).

          (Z(:^

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nizeguy
            wrote on last edited by
            #5

            That opengl stuff should be equivalent to embedding a QGLWidget.

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              "should" is the keyword. As far as I remember the discussion, devs from qt-project have tried a lot to make them fit together, but failed. That is why there is a big split between QtGui and QtWidgets now. But as I have mentioned earlier - I'm not sure I remember it all correctly. Ask on dev ML or search it's archive.

              (Z(:^

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dbzhang800
                wrote on last edited by
                #7

                Give to a try to this?

                http://code.google.com/p/h-qt-exercise/source/browse/qt3d/windowwidget/windowwidget.h

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lendrick
                  wrote on last edited by
                  #8

                  For anyone reading this, there's a relevant Qt bug that you might want to follow:

                  https://bugreports.qt-project.org/browse/QTBUG-25643

                  I can confirm that the winddowwidget code (from the comment above) works for QQuickView (as well as the general case) and have updated the bug accordingly. Hopefully this makes it into 5.0.0, since it strikes me as necessary functionality. If not, at least it's small.

                  I think the blocker on this was putting QWidgets into a QQuickView, which this doesn't allow you to do. That said, I think you should be able to render QWidgets on top of it with no issue (in case you're using right-click menus, etc).

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    nizeguy
                    wrote on last edited by
                    #9

                    As any solution for this missing feature been included in latest Qt ?

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mbreier
                      wrote on last edited by
                      #10

                      No not yet.
                      Until now you need to go the way by using the windowwidget workaround

                      Update:
                      https://codereview.qt-project.org/#change,44285

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        filushka
                        wrote on last edited by
                        #11

                        Here is the solution for QT 5.2.1
                        You must pre-install Win32OpenSSL

                        QQuickView view_main;
                        view_main.resize(683, 384);
                        view_main.setResizeMode(QQuickView::SizeRootObjectToView);
                        view_main.setSource(QUrl("qrc:///res//main_page.qml"));
                        //view_main.show();

                        QQuickItem *item_main = (QQuickItem*) view_main.rootObject();
                        QWindow* main_page = item_main->window();
                        QObject *button_logoff = item_main->findChild<QObject*>( "button_logoff" );
                        
                        if( button_logoff )
                            QObject::connect( button_logoff, SIGNAL(clicked()), ms, SLOT( on_button_logoff() ) );
                        else
                            qDebug() << "button_logoff is NULL";
                        
                        if( main_page )
                        {
                            QWidget *container = QWidget::createWindowContainer( main_page );
                            stacked_widget->addWidget( container );
                        }
                        else
                           qDebug() << "main_page is NULL";
                        
                        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