When I create a QGLWidget with a custom GLFormat and set that widget as viewport of a qgraphicsview, if the glformat is higher than 3.1, the graphicsview stop drawing graphicsobjects or graphicsitems.
example( if I setVersion(3,1) the img pixmap is drawn, if I setVersion(3,3) the img pixmap doesn't appear in the scene):
glFormat.setVersion(3,1);
//glFormat.setVersion(3,3);
glFormat.setOption(QGL::DoubleBuffer);
glFormat.setOption(QGL::DepthBuffer);
glFormat.setOption(QGL::Rgba);
img->setPos(100,100);
scene->addItem(img);
graphicsView->setViewport(widget);
graphicsView
->setViewportUpdateMode
(QGraphicsView::FullViewportUpdate);
graphicsView->setScene(scene);
QGLFormat glFormat;
glFormat.setVersion(3,1);
//glFormat.setVersion(3,3);
glFormat.setProfile(QGLFormat::CoreProfile);
glFormat.setOption(QGL::DoubleBuffer);
glFormat.setOption(QGL::DepthBuffer);
glFormat.setOption(QGL::Rgba);
QGLWidget* widget = new QGLWidget(glFormat);
QGraphicsView *graphicsView = new QGraphicsView();
QGraphicsScene *scene = new QGraphicsScene();
QGraphicsPixmapItem *img = new QGraphicsPixmapItem(QPixmap("btn-easy.png"));
img->setPos(100,100);
scene->addItem(img);
graphicsView->setViewport(widget);
graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
graphicsView->setScene(scene);
To copy to clipboard, switch view to plain text mode
Any idea if it can be fixed? Or something that I'm doing wrong?
I was using the http://doc.qt.digia.com/qq/qq26-openglcanvas.html openglcanvas approach to draw transparent items on top of a GLWidget. But since my custom GLWidget (it happens with default QGLWidget like on the example) requires OpenGL higher than 3.1 (actually should be 4.x), I cannot keep this approach.
Anyone know another efficient approach to draw transparent widgets on top of a QGLWidget or how to set a graphicview viewport with a qglwidget using glcontext 4.x?
QT5 handles the graphic pipeline differently from the QT4 , can QT5 be a solution? Did anyone successfully made an openGLCanvas on QT5?
Thanks in advance.
Bookmarks