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. OpenGLWidget in QDockWidget stays black while floating
QtWS25 Last Chance

OpenGLWidget in QDockWidget stays black while floating

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 1.0k Views
  • 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.
  • gde23G Offline
    gde23G Offline
    gde23
    wrote on last edited by
    #1

    Hello,

    I have a class derived from QOpenGLWidget. When I put it on the mainwindow or in a QDialog it works as intend.
    However when I add the same widget to a QDockWidget it stays black, but only when its floating. As long as it is docked it also works.

    I've also tried to subclass QDockWidget and add

    QSurfaceFormat fmt;
    QSurfaceFormat::setDefaultFormat(fmt);
    

    To the constructor, but that does not help.
    Any ideas how to solve this?

    (I'm using Qt5.15 on Debian)

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Dariusz
      wrote on last edited by
      #2

      +1 from me too. Had that problem since start. Docket widgets with OpenGL works, but floating are just black.

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

        Hi,

        Please provide a minimal compilable example that shows the behaviour.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        gde23G 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Please provide a minimal compilable example that shows the behaviour.

          gde23G Offline
          gde23G Offline
          gde23
          wrote on last edited by gde23
          #4

          @SGaist
          I've set up a minimal example based on the OpenGL Cube example in QtCreator.
          You can download it here

          However in the example the OpenGL widget is getting gray not black when undocked, so it differs a bit from the other project.
          I still hope it can show the problem.
          EDIT: also what I noticed. When I directly set it flaoting in the constructor its fine as well. So its not the floating, but the docking/undocking that kills it.

          1 Reply Last reply
          0
          • gde23G Offline
            gde23G Offline
            gde23
            wrote on last edited by
            #5

            Can anybody confirm this is a bug?
            Then I'll submit it to the bug tracker.

            mrjjM 1 Reply Last reply
            0
            • gde23G gde23

              Can anybody confirm this is a bug?
              Then I'll submit it to the bug tracker.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @gde23
              Hi
              Sorry missed your post.
              Download it and it ran fine

              as soon as i drag the caption
              it goes
              alt text

              Win 10, Qt 5.15.1, visual stud. compiler 2019

              1 Reply Last reply
              2
              • gde23G Offline
                gde23G Offline
                gde23
                wrote on last edited by
                #7

                @mrjj Thanks a lot for checking.

                I'll submit it to the bug tracker then.

                Also I just found a work around how it can be fixed.
                Setting

                QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
                

                Will solve the problem. I though haven't tested out if this will lead to other problems yet.

                mrjjM 1 Reply Last reply
                1
                • gde23G gde23

                  @mrjj Thanks a lot for checking.

                  I'll submit it to the bug tracker then.

                  Also I just found a work around how it can be fixed.
                  Setting

                  QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
                  

                  Will solve the problem. I though haven't tested out if this will lead to other problems yet.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  Hi
                  Np, when providing a full project that i can just run :) any time then.

                  Ah that kinda makes sense when you show it :)
                  So when in Mainwindow they are part of the same context but when in a window (floating)
                  they need to share the context. ( or something like that )

                  https://forum.qt.io/topic/63771/multiple-contexts-using-qopenglwidget/2

                  I dont think you will get any issues with it as it seems to be made for such case.

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

                    Sorry, I lost track of your post. But glad you found a workaround !

                    I agree with @mrjj, it should not bring you trouble.

                    Thanks for opening the issue. Please post the link here so it's easier to find :-)

                    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
                    • gde23G Offline
                      gde23G Offline
                      gde23
                      wrote on last edited by
                      #10

                      https://bugreports.qt.io/browse/QTBUG-89812

                      SGaistS 1 Reply Last reply
                      2
                      • gde23G gde23

                        https://bugreports.qt.io/browse/QTBUG-89812

                        SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @gde23 said in OpenGLWidget in QDockWidget stays black while floating:

                        https://bugreports.qt.io/browse/QTBUG-89812

                        Thanks !

                        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