Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-47332

QOpenGLWidget causes corruption when using winId() on another QWidget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.5.0
    • GUI: OpenGL
    • None
    • Window 7 64 bits.

    Description

      When requesting the winId() of a QWidget in the same parent widget as a QOpenGLWidget, some of these widgets will fail to display properly and will cause a huge lag in display updates for everything that does still seem to work.

      This can be easily shown in this example http://doc.qt.io/qt-5/qtopengl-2dpainting-example.html
      First, in main.cpp main() adding this line prevents even more problems:
      app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);

      Several error cases, adapt Window::Window() in window.cpp:

      • add at the end of the constructor:
        nativeLabel->winId();
        This will cause the nativeLabel to show a blank area (opengl is still working)
      • add at the end of the constructor:
        native->winId();
        This will cause the native display to show a blank area (opengl is still working)
      • comment out:
        GLWidget *openGL = new GLWidget(&helper, this);
        connect(timer, SIGNAL(timeout()), openGL, SLOT(animate()));
        This will cause the previously blank areas to function properly again, but obviously we don't have an opengl display anymore

      I'm running into this problem because I'm upgrading from Qt 5.1 to Qt 5.5 and we're using Ogre3D for 3d visualization, which requires a winId() at some point to initialize itself. We have a single MDI window per file that can contain OpenGL graphs (QOpenGLWidget) and the 3D visualization.

      Final note, in our application if we don't set app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); in main() as soon as we show (not create, but show) a QOpenGLWidget that has this conflict, pretty much all other Qt Visualizations seem to refuse to update, but there are silly things that seem to work: Dragging a scrollbar doesn't update the display, but clicking in the empty area so it jumps one page does cause an immediate update, etc.
      If we do set the attribute, that part at least goes away, but in our case the OpenGL won't render, while the rest displays fine. This seems to be the oppposite behavior of the example code, but I'm pretty sure it's a symptom of the same bug.

      Edit:
      I'm doing this on a Windows 7 machine. We also tried it on Kubuntu, where we don't see blank areas, but the 'native' widget doesn't update after its first frame.
      On windows: if I construct a widget with a null parent, then request the winId() and then add it to the layout I always get an "Attempt to set a screen on a child window." warning (from QWindowPrivate::setTopLevelScreen), which doesn't happen on Kubuntu.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              lagocs Laszlo Agocs
              wathiant Job Mulder
              Votes:
              4 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes