Hi!

I followed the discussion and I am very interested in being able to use OpenGL commands inside the paint() code of the items in my scene. Actually, I have started implementing this, with great success.

Here's a schematic overview of how I've done:
Qt Code:
  1. //...
  2. QGraphicsView view(&scene);
  3. //the following line adds the opengl support
  4. view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers | QGL::Rgba)));
  5.  
  6. //here's my item class
  7. class GLGraphicsItem : public QGraphicsItem
  8. {
  9. //...
  10. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
  11. {
  12. Q_UNUSED(option);
  13. Q_UNUSED(widget);
  14. if (painter->paintEngine()->type() != QPaintEngine::OpenGL)
  15. qWarning("OpenGLScene: drawBackground needs a "
  16. "QGLWidget to be set as viewport on the "
  17. "graphics view");
  18. else{
  19. //opengl commands here
  20. }
  21. }
  22. //...
  23. }//end-class
To copy to clipboard, switch view to plain text mode 
The ablove code works nicely and does what it shoud - if I just display the view.

Now I tried to use the view function
Qt Code:
  1. QGraphicsView::render ( QPainter * painter, const QRectF & target = QRectF(), const QRect & source = QRect(), Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio )
To copy to clipboard, switch view to plain text mode 
which will output the warning message, i.e. this rendering is performed *without* opengl support.

I do not need the fastest hardware acceleration for this offscreen rendering at this point, just the opengl commends are very important for me.