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
Description
a `QGraphicsView` with `QOpenGLWidget` as viewport,
when:
- set `QGraphicsView` directly to `QMainWindow`, view could be seen;
- but, if just add the view to the `QTabWidget`, the view's contents missed, and widget area turned dark.
- 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.