Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using QGLWidget and QQuickWidget a the same time?
Forum Updated to NodeBB v4.3 + New Features

Using QGLWidget and QQuickWidget a the same time?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.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.
  • S Offline
    S Offline
    Sushisource
    wrote on last edited by
    #1

    I have an app (music player) which uses QGLWidget for rendering a visualizer, and used to use QQuickView and QWidget::createWindowContainer() for creating some of the GUI. I saw that QQuickWidget is the replacement for that technique in 5.3, but upon switching to it I'm finding that the QQuickWidget renders only black as long as the QGLWidget has been instantiated. If I never create the QGLWidget, it works fine.

    Is this expected? Can the two not be used together? Is there a workaround?

    Any help is appreciated. I'm happy to provide code samples if that helps.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bwilli
      wrote on last edited by
      #2

      I experience something similar using QQuickWidget in an application containing the previous technique for embedding QML in QWidget applications: QQuickView and QWidget::createWindowContainer.

      When I do NOT invoke QWidget::createWindowContainer to create a qml widget, everything works fine, the other "new style" QQuickWidget ist displayed.

      When I invoke QWidget::createWindowContainer for creating the legacy widgets, the new QQuickWidget stays black.

      Platform is Windows 7 x64.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        potvete
        wrote on last edited by
        #3

        There is a bug report for this issue: "QTBUG-39316":https://bugreports.qt-project.org/browse/QTBUG-39316

        As Laszlo says in a comment, the workaround is to call:
        @QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings)@

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sushisource
          wrote on last edited by
          #4

          Hmm, unfortunately the workaround isn't doing it for me, the QQuickWidget is still black. I tried putting it as the first line in main() as suggested in the bug.

          Thanks for the pointer to the bug though, at least it's actively being worked on.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sushisource
            wrote on last edited by
            #5

            For those googling:

            A temporary workaround for me was to add this line to the widget inheriting from QGLWidget:
            this->setAttribute(Qt::WA_DontCreateNativeAncestors);

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sevketcaba
              wrote on last edited by
              #6

              try adding QQuickWidget instance when the parent widget layout has been set, if necessary, use QMetaObject's invokeMethod with queued connection (or maybe invoke it with a QTimer::singleShot).

              It will solve the problem, but here is the weird thing, i use OpenSceneGraph in my QGLWidget, and QQuickWidget stops updating itself. I have to resize or unfocus-focus to make QQuickWidget draw itself. I tried to set a timer to QQuickWidget's update slot, but had no chance.

              P.S. used repaint instead of update, and it seems working right now. I will check the stability.

              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