Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
4.7.4, 4.8.1
-
None
Description
If we take a transparent widget an put it over a QGraphicsView, the background of the widget is the part of the view just behind it. But now, if we set the viewport to a QGLWidget, the backround of the widget will be an never painted one.
The minimal code to show that is :
#include <QtGui/QApplication> #include <QLabel> #include <QGraphicsView> #include <QGraphicsPixmapItem> #include <QGLWidget> int main(int argc, char *argv[]) { QApplication a(argc, argv); QGraphicsView v; //v.setViewport(new QWidget); v.setViewport(new QGLWidget); v.setBackgroundBrush(QBrush(Qt::white)); QGraphicsScene s; s.addEllipse(25, 35 ,122, 122, QPen(Qt::red), QBrush(Qt::red)); s.addRect(100, 100, 120, 120, QPen(Qt::green), QBrush(Qt::green)); v.setScene(&s); //Here we use a QLabel but the bug is the same with all the widgets //QLabel* label = new QLabel("Without OpenGL", &v); QLabel* label = new QLabel("With OpenGL", &v); label->setStyleSheet("QLabel{background: transparent; color: blue; font: 30px;}"); label->move(10, 10); v.show(); return a.exec(); }
Which renders :
As you can see in the picture above, there are artifacts of the scrolls bars behind the text of the label. It’s not specific for QLabels so all the widgets with transparent backgrond are drawn like that. This is a problem in many cases when we have to paint UIs over a OpenGL rendered graphical view.