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 QStackedLayout for overlaying an OpenGL widget
Forum Updated to NodeBB v4.3 + New Features

Using QStackedLayout for overlaying an OpenGL widget

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 2.5k 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.
  • P Offline
    P Offline
    pjpetitprez
    wrote on last edited by
    #1

    Hi,

    I am currently tring to use a QStackedLayout to add overlay widgets on top of an OpenGL widget (not a QOpenGLWidget, but a regular QWidget in which I draw with an external graphics engine thanks to the window handle). I have set the QStackedLayout stacking mode to "StackAll" in order to see the whole widget stack.
    But I can't get to see the OpenGL widget under my overlay widget. It always appears like if the OpenGL widget was "discarded", just like if there was nothing drawn in it but just fully transparent.

    Is there any hint with using a QStackedWidget to achieve what I want to do? Or maybe is it not the correct solution?

    Thanks.

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

      Hi and welcome to devnet,

      Can you share a sample code where you setup that ?

      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
      0
      • P Offline
        P Offline
        pjpetitprez
        wrote on last edited by pjpetitprez
        #3

        Here is how I try to use it.

        QWidget* mainWidget;
        QStackedLayout *stackedLayout = new QStackedLayout;
        mainWidget->setLayout(stackedLayout);
        
        QWidget* ogreWidget = new QWidget();
        ... // code to create OGRE context
        stackedLayout->addWidget(ogreWidget);
        
        QWidget* overlayWidget;
        QVBoxLayout* vBoxLayout = new QVBoxLayout();
        vBoxLayout->setContentsMargins(0, 0, 0, 0);
        overlayWidget->addLayout(hBoxLayout);
        ... // Some child widgets created and added to the overlayWidget
        stackedLayout->addWidget(overlayWidget);
        
        stackedLayout->setStackingMode(QStackedLayout::StackAll):
        
        

        The widget named ogreWidget is a QWidget in which I render an OpenGL scene with OGRE3D. I get the winId of the widget and I send it to OGRE, and then OGRE owns its OpenGL context and manages it.
        With this code I can correctly see the overlay widgets, but the OGRE widget underneath seems to be discarded, I see only the widget which is under the mainWidget (but Debug mode showed me that the rendering is made, the widget seems to be updated correctly). If I deactivate the overlay stack, the OGRE widget is correctly showing.

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

          What about positioning your overlay widget by hand rather that through QStackedLayout ?

          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
          0
          • P Offline
            P Offline
            pjpetitprez
            wrote on last edited by
            #5

            Well I have found out that using a QGraphicsScene to host my overlaying widgets seems to be working and it is easy to manipulate them, so I'll go with the QGraphicsView / QGraphicsScene solution.
            Thanks

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

              Good idea !

              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
              0

              • Login

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