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

QGraphicsView with QOpenGLWidget as viewport got dark in QTabWidget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.8, 5.15.2, 6.2.1
    • None
    • Ubuntu 20.04 (Qt 5.12.8)
      Linux kernel 5.11.0-40-generic

      Archlinux (Qt 5.15.2 and Qt 6.2.1)
      Linux kernel 5.14.16-arch1
    • Linux/X11

    Description

      a `QGraphicsView` with `QOpenGLWidget` as viewport,

      when:

      1. set `QGraphicsView` directly to `QMainWindow`, view could be seen;
      2. but, if just add the view to the `QTabWidget`, the view's contents missed, and widget area turned dark.
      3. however, I tried add the view to other containers like `QStackedWidget`

       

      For example, embed the graphics view to a mainwindow, add add a graphics item the the scene:

      GraphicsView code:

      QGarphicsScene *scene = new QGraphicsScene();
       QGraphicsView *view = new QGraphicsView(scene);
       view->setViewPort(new QOpenGLWidget);
      

      example 1: view can be seen

       QMainWindow w;
       w.setCentralWidget(view);
       w.show();
       scene->addRect(QRect(50, 50, 50, 50));
      

      example 2: add view to tab widget, the view can not be seen

       QMainWindow w;
       QTabWidget* t = new QTabWidget;
       t->addTab(view, "view");
       w.setCentralWidget(t);
       w.show();
       scene->addRect(QRect(50, 50, 50, 50));
      

      example 3: add view to stacked widget

       QMainWindow w;
       QStackedWidget* stacked = new QTabWidget;
       stacked->addWidget(view);
       w.setCentralWidget(stacked);
       w.show();
       scene->addRect(QRect(50, 50, 50, 50));
      

       

      terminal message in example 2:

      QPainter::begin: Paint device returned engine == 0, type: 1
      QPainter::setRenderHint: Painter must be active to set rendering hints
      QPainter::setRenderHint: Painter must be active to set rendering hints
      QPainter::setWorldTransform: Painter not active
      QPainter::worldTransform: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::end: Painter not active, aborted
      

      example 1, 2 and 3's result screen shot attached in attachments.

      Attachments

        1. example_1.png
          example_1.png
          2 kB
        2. example_2.png
          example_2.png
          3 kB
        3. example_3.png
          example_3.png
          2 kB
        4. GraphicsIssue.tar.xz
          6 kB

        Activity

          People

            bibr Andreas Aardal Hanssen
            ytexas Forrest Young
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: