[Interest] smoothest way to zoom/pan QGraphicsView?

Ch'Gans chgans at gna.org
Fri Apr 7 05:40:47 CEST 2017


On 7 April 2017 at 15:02, Patrick Stinson <patrickkidd at gmail.com> wrote:
>
>> On Apr 6, 2017, at 7:57 PM, Ch'Gans <chgans at gna.org> wrote:
>>
>> On 7 April 2017 at 14:38, Patrick Stinson <patrickkidd at gmail.com> wrote:
>>> I am implementing a pan and zoom on pinch via raw touch events and am finding setTransform() to be very slow, even with an empty scene. The touch events are backed up in a queue by slow synchronous calls to QGraphicsView.setTransform().
>>
>> If it's slow with an empty scene, then you have a problem that has
>> nothing to do with QTransform. Maybe you have a cascade of events that
>> bounce on each other until it stabilise...
>> Maybe your synchronous calls are too frequent. I would advise to use
>> the animation framework to do this sort of things.
>
> This is possible. I will check further.
>
>>
>> Whats your environment, which HW, which OS, which Qt, …
>
> I am using Qt-5.8.1 and PyQt-5.8.1, latest sierra with latest MacBook pro
>
>>
>>>
>>> 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?
>>
>> Use the animation framework. no need for a queue mechanism, should
>> work without any problems unless you hardware is not powerful enough.
>>
>
> How would one animate the transform without a "transform" property? Or am I missing something? (I’ve been away from qt for a while - since before the animation framework)
>

I didn't say w/o a "transform" property, i said w/o a queue. My point
is that using the animation framework will likely be easier and gives
smoother result than using QTimer and a "command queue".
BTW, you cannot animate the "transform" property without providing
your own interpolation function.
But you can work around that by animating scale factor and translation.

PS: I've just found this
https://wiki.qt.io/Smooth_Zoom_In_QGraphicsView, haven't tried it, but
this might help you in your quest.

Chris

>
>> Chris
>>
>>>
>>> Thanks!
>>> -P
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
>



More information about the Interest mailing list