The application I'm working on has several animating objects (rotating in a circle) and I'm looking to lower the CPU consumed. I'm using the graphicsview framework and most objects on the screen, including the animating objects are derived from QGraphicsWidget.

I do set the viewport to QGLWidget so I get some OpenGL acceleration but that isn't lowering the CPU enough.

I see setting the viewport to QGLWidget changes the paint engine to QOpenGLPaintEngine and translates a lot of the painter calls to OpenGL calls. Looking through the source and stepping through in debug, I come across this function of particular interest:

Qt Code:
  1. void QGLDrawable::setDevice(QPaintDevice *pdev)
  2. {
  3. ...
  4. if (pdev->devType() == QInternal::Widget)
  5. widget = static_cast<QGLWidget *>(pdev);
  6. else if (pdev->devType() == QInternal::Pbuffer)
  7. buffer = static_cast<QGLPixelBuffer *>(pdev);
  8. else if (pdev->devType() == QInternal::FramebufferObject)
  9. fbo = static_cast<QGLFramebufferObject *>(pdev);
  10. else if (pdev->devType() == QInternal::UnknownDevice)
  11. ...
  12. }
To copy to clipboard, switch view to plain text mode 

It looks like this paint engine has the ability to render into a framebuffer object and this would probably give me a nice gain in performance (platform does support framebuffer objects).

The only problem is I don't see how to change an object's PaintDevice. For all my objects the PaintDevice is of type Widget, which is expected.

Does anyone know how I can change the PaintDevice to FramebufferObject?

I've thought of changing this file to always use frame buffers but it seems there should be a way to set this.