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. Black screen with QOpenGLWidget while docking
Qt 6.11 is out! See what's new in the release blog

Black screen with QOpenGLWidget while docking

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.2k 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.
  • A Offline
    A Offline
    aabb2137
    wrote on last edited by aabb2137
    #1

    Environment:
    QOpenGLWidget inside a QWidget, added to a QStackedWidget, inside a QDockWidget
    Qt 6.10.0 Windows

    Problem:
    I have a file browser widget (QDockWidget) that lazily creates a QOpenGLWidget-based 3D viewer when the user opens a file. The widget is added to a QStackedWidget via addWidget() and made current.
    It displays correctly and everything works fine, but when the QWidget is docked the OpenGL window becomes black. After undocking it is normal again.
    If you dock QWidget (before starting opengl scene) and then start it everything works fine.
    Also if you open the file for the first time:
    a) when floating QWidget flashes (disappears and appears again)
    b) when its docked the whole main window flashes

    Also the screen is black but if I press the settings button (I can't see) the menu shows normally and I see it

    Already tried the AA_ShareOpenGLContexts, delaying repainting.

    1 Reply Last reply
    0
    • Joe von HabsburgJ Offline
      Joe von HabsburgJ Offline
      Joe von Habsburg
      wrote on last edited by
      #2

      I'm experiencing a similar issue. When the first OpenGLWidget is added to my DockWidget, it flashes—that is, it quickly alternates between hidden and visible. However, this only happens with the first OpenGLWidget. If I add another one, the problem doesn't occur. Do you have any suggestions?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aabb2137
        wrote on last edited by
        #3

        Same thing here. I managed to get rid of the black screen by initializing it earlier (I was using lazy initialization). However, the flash still appears, and as you can see, it happens only the first time it starts.

        Maybe creating it at the start of the program and then hiding it could be a workaround.

        Joe von HabsburgJ 1 Reply Last reply
        1
        • A aabb2137

          Same thing here. I managed to get rid of the black screen by initializing it earlier (I was using lazy initialization). However, the flash still appears, and as you can see, it happens only the first time it starts.

          Maybe creating it at the start of the program and then hiding it could be a workaround.

          Joe von HabsburgJ Offline
          Joe von HabsburgJ Offline
          Joe von Habsburg
          wrote on last edited by
          #4

          @aabb2137 said in Black screen with QOpenGLWidget while docking:

          Maybe creating it at the start of the program and then hiding it could be a workaround.

          //Mainwindow constr
          
              auto *dummyGL = new QOpenGLWidget(this);
              dummyGL->show();
              dummyGL->hide();
          

          This solved my flashing problem, but is it correct solution ?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aabb2137
            wrote on last edited by
            #5

            For me it does not work (it fixed the black but not the flashing). I'm not a huge fun of creating it at the start and I think there is a better solution but I can't find it

            1 Reply Last reply
            0
            • F Offline
              F Offline
              finmark
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • J Offline
                J Offline
                jimmiejim
                wrote on last edited by
                #7

                The flashing happens because of
                "Note: When dynamically adding a QOpenGLWidget into a widget hierarchy, e.g. by parenting a new QOpenGLWidget to a widget where the corresponding top-level widget is already shown on screen, the associated native window may get implicitly destroyed and recreated if the QOpenGLWidget is the first of its kind within its window. This is because the window type changes from RasterSurface to OpenGLSurface and that has platform-specific implications. This behavior is new in Qt 6.4."
                as stated in https://doc.qt.io/qt-6/qopenglwidget.html#limitations-and-other-considerations.

                If you create a tiny invisible dummy QOpenGLWidget and parent it before the widget is embedded into the main window, it should work seamlessly.

                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