Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsItem's paintEngine changed during program runing

QGraphicsItem's paintEngine changed during program runing

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TZQQ
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TZQQ
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        T 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

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

          T Offline
          T Offline
          TZQQ
          wrote on last edited by
          #4

          @SGaist
          Qt5.5-msvc2013
          Win 10

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved