Accelerate your widgets with OpenGL

To breathe some new life into the graphics dojo, here's an example of how to put widgets on top of an OpenGL scene using QGraphicsView. By leveraging the synergy (tounge in cheek) of the OpenGL module and graphics view's in 4.4 new widget capabilities, the long lacking feature of putting widgets in OpenGL becomes possible. All that's needed is to set a QGLWidget as viewport on the graphics view, override QGraphicsScene::drawBackground() to do the OpenGL rendering, and add widgets and other graphics items to the graphics scene as usual. The result can be seen in the screenshot below, which shows a simple obj-model viewer application written in just a couple of hundred lines of code:

Widgets on top of an OpenGL scene

The source code is available by "svn checkout svn://labs.trolltech.com/svn/graphics/dojo/modelviewer". Have fun!

Update (8 Feb 2010): Latest version of source code with some new patches is available at http://qt.gitorious.org/qt-labs/modelviewer


Blog Topics:

Comments