QGraphicsItem's paintEngine changed during program runing
Unsolved
General and Desktop
-
Hi guys,
To speed up the QGraphicView system, I render it with OpenGL, set the Viewer's viewport to GLWidget:
setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer)));
In the GraphicItem paint function, monitor the paintEngine:
void Item::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QWidget* vp = scene()->views().front()->viewport(); QGLWidget* glw = qobject_cast<QGLWidget*>(vp); //qDebug() << "viewport" << glw->format(); qDebug() << this->parent() << this->parentItem(); bool ok = false; int type = painter->paintEngine()->type(); if (type == QPaintEngine::OpenGL2) ok = true; qDebug() << (int)this << type; }
In the debug output information, at first the type is 14(GL2), after some operation(diffcult to analsys), the output change to 10(Raster).
Any suggestion for debug?
-
Hi and welcome to devnet,
Which version of Qt are you using ? On which OS ?
-
Can you use a more recent version ?
Also note that QGLWidget has been deprecated for QOpenGLWidget.