[Interest] QGraphicsView widget vs opengl viewport

Calogero Mauceri mauceri at actgate.com
Tue Nov 27 16:36:57 CET 2012

Il 27/11/2012 16.24, Samuel Rødal ha scritto:
> On 11/27/2012 03:36 PM, Calogero Mauceri wrote:
>> Hi,
>> In my application I have a QGrapricsScene with a big amount of polygon
>> items in it (more than 50,000 QGraphicsPolygonItem).
>> I found out in the documentation that it is possible to set a QGLWidget
>> as the viewport of the QGraphicsView.
>> "By default, QGraphicsView provides a regularQWidget
>> <http://qt-project.org/doc/qt-4.8/qwidget.html>for the viewport widget.
>> You can access this widget by callingviewport
>> <http://qt-project.org/doc/qt-4.8/qabstractscrollarea.html#viewport>(),
>> or you can replace it by callingsetViewport
>> <http://qt-project.org/doc/qt-4.8/qabstractscrollarea.html#setViewport>().
>> To render using OpenGL, simply call setViewport(newQGLWidget
>> <http://qt-project.org/doc/qt-4.8/qglwidget.html>)."
>> As far as I understand that should work out of the box, without any
>> additional code. The system should use automatically opengl rendering
>> from now on.
>> My question is, can my QGraphicsScene benefit of the OpenGL rendering?
>> Do you think I should always enable it? Are there some cases where the
>> classic widget viewport can work better?
>> Is the QGraphicsScene OpenGL rendering well supported on multiple
>> platforms (Win, linux, Mac)?
>> I'm using Qt 4.8.3.
>> Thanks in advance for your advice,
>>       Calogero
> Performance wise you can get quite large benefits from using a QGLWidget
> viewport. Quality wise the rendered output might look slightly worse,
> with lower antialiasing quality and less precise rounding of lines and
> other primitives.
> It depends on whether you find the rendered output acceptable for use case.
> --
> Samuel

If it is just a matter of performace vs quality, then I'll choose the 
OpenGL rendering. Currently I'm even disabling the antialising in the 
qgraphicsview trying to speed up the rendering a little bit


Thank you very much for your hint!

Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)

More information about the Interest mailing list