[Interest] QGraphicsView widget vs opengl viewport
Samuel Rødal
samuel.rodal at digia.com
Tue Nov 27 16:24:56 CET 2012
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
More information about the Interest
mailing list