Results 1 to 4 of 4

Thread: QGraphicsView stop drawing objects when a glwidget with GLVersion>3.1 set as viewport

  1. #1
    Join Date
    Jul 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsView stop drawing objects when a glwidget with GLVersion>3.1 set as viewport

    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):
    Qt Code:
    1. QGLFormat glFormat;
    2. glFormat.setVersion(3,1);
    3. //glFormat.setVersion(3,3);
    4. glFormat.setProfile(QGLFormat::CoreProfile);
    5. glFormat.setOption(QGL::DoubleBuffer);
    6. glFormat.setOption(QGL::DepthBuffer);
    7. glFormat.setOption(QGL::Rgba);
    8. QGLWidget* widget = new QGLWidget(glFormat);
    9. QGraphicsView *graphicsView = new QGraphicsView();
    10. QGraphicsPixmapItem *img = new QGraphicsPixmapItem(QPixmap("btn-easy.png"));
    11. img->setPos(100,100);
    12. scene->addItem(img);
    13. graphicsView->setViewport(widget);
    14. graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    15. 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.
    Last edited by raziel; 11th December 2012 at 19:56.

  2. #2
    Join Date
    Jul 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView stop drawing objects when a glwidget with GLVersion>3.1 set as view

    A co-worker solved the problem.
    There is no need to setVersion on the glwidget glformat that will be set as viewport of a graphicsview, the qt itself use the current available maximum glversion, as long as QGLFormat::CoreProfile is set.

  3. #3
    Join Date
    May 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: QGraphicsView stop drawing objects when a glwidget with GLVersion>3.1 set as view

    Quote Originally Posted by raziel View Post
    A co-worker solved the problem.
    There is no need to setVersion on the glwidget glformat that will be set as viewport of a graphicsview, the qt itself use the current available maximum glversion, as long as QGLFormat::CoreProfile is set.
    Unfortunately, that isn't true if you're using OSX.
    You need to set the OGL version (with QGLFormat) if you're need the 2.1> GLSL context, but if you do that, the QGraphicItems are not drawed.

    This issue is killing me...
    I didn't find a solution yet.

    Regards,
    Rodrigo Haller

  4. #4
    Join Date
    Jul 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView stop drawing objects when a glwidget with GLVersion>3.1 set as view

    Hi,
    Sorry I can't help you out. When I had this issue I really tried everything I could and nothing worked out. The only thing that fixed the problem was not setting the ogl version, I was using windows but my co worker used osx and worked too. If I didn't type any glFormat.setVersion it would draw everything, and if i query the current version in a breakpoint or print would give my current graphic ogl version. Are you sure that your graphic card support that ogl version? (for instance if you have 2 graphic cards, your app might be using yout intel hd with ogl 2.1 support only) Have you tried new qt graphic classes ( i dunno how it turned out but when qt5 was released there was some new graphic classes i didnt explore, they might work better)?
    good luck on solving this issue

Similar Threads

  1. Replies: 2
    Last Post: 15th June 2021, 17:00
  2. QGraphicsView inside of QAbstractItemView viewport
    By Paladin12 in forum Qt Programming
    Replies: 5
    Last Post: 24th January 2016, 15:15
  3. Replies: 5
    Last Post: 9th January 2012, 22:22
  4. Replies: 0
    Last Post: 28th April 2010, 12:41
  5. Replies: 0
    Last Post: 8th April 2010, 17:06

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.