QGraphicsItem's paintEngine changed during program runing



  • 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?



  • Update: the widget changed to 0x0 rather than the QGLWidget when problem occurs.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Which version of Qt are you using ? On which OS ?



  • @SGaist
    Qt5.5-msvc2013
    Win 10


  • Lifetime Qt Champion

    Can you use a more recent version ?
    Also note that QGLWidget has been deprecated for QOpenGLWidget.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.