[Interest] smoothest way to zoom/pan QGraphicsView?

Ch'Gans chgans at gna.org
Fri Apr 7 15:56:15 CEST 2017

On 7 April 2017 at 19:41, Jean-Michaël Celerier
<jeanmichael.celerier at gmail.com> wrote:
> In my experience setting a GL viewport makes everything much less snappy (at
> least on linux & os x, did not test on windows).
> Here is a video of my software with GL viewport: https://vid.me/kjRe
> And without: https://vid.me/e2vu
> As you can see (as far as one can see in such a video), when I move the
> object with the GL viewport there is a visible lag between the position of
> the cursor and the position of the object ; much less when there is only
> software rendering.
> The experience is even worse on macOS, but maybe because of the performance
> cost of retina.
> I also tried porting the main view to QtQuick 2 but it is roughly the same
> "laggy" performance.

My experience with QGraphicsView and GL viewport is that it can
actually slow down the rendering. This is especially true when you
have lot of small static items (by a lot i mean 1K+).
After lot of trial, i decided that _in my case_, there was no point
using GL viewport, it gave me more problems than benefits.
Big QPainterPath with OpenGL will cause trouble as well, i use to get
every now and then warning messages like 'QPainterPath size is greater
than 32K pixels!' and a black viewport...
The QGraphicsView Framework is a nice piece of software, but it takes
lot of time to discover its quirks and limitations.
QGraphicsPathItem has serious problems as well when used in a scene
where you have to deal with small sizes (eg, better use a
QGraphicsScene 'resolution' of 1.0 than 1E-6. QPainterPath uses
QPointF but doesn't scale well, it is still a screen/pixel primitive.


> Best
> -------
> Jean-Michaël Celerier
> http://www.jcelerier.name
> On Fri, Apr 7, 2017 at 7:04 AM, Thiago Macieira <thiago.macieira at intel.com>
> wrote:
>> Em quinta-feira, 6 de abril de 2017, às 19:38:36 PDT, Patrick Stinson
>> escreveu:
>> > Without stripping down my code into a runnable example, is setTransform
>> > considered to be too slow for 60Hz frame-rate updates from touch events?
>> > If
>> > so, is there a better way to smoothly zoom and pan the graphics view?
>> QGraphicsView is not architected correctly for smooth 60 fps.
>> At least try to set a QOpenGLWidget as your viewport. It might help.
>> --
>> Thiago Macieira - thiago.macieira (AT) intel.com
>>   Software Architect - Intel Open Source Technology Center
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

More information about the Interest mailing list