[Interest] QML Custom Scene Graph animation?

Mark markg85 at gmail.com
Tue Jun 4 23:46:37 CEST 2013


On Tue, Jun 4, 2013 at 11:40 PM, Alan Alpert <416365416c at gmail.com> wrote:
> On Tue, Jun 4, 2013 at 1:51 PM, Mark <markg85 at gmail.com> wrote:
>> Hi,
>>
>> I'm playing with custom QML components in Scene Graph. The kind of
>> component that i want to make is a system monitor like component (and
>> learning Scene Graph while doing that is a big plus). Now i'm a bit
>> stuck in the animation area. I can - obviously - just draw a line in
>> some custom component and then move that component in either x or y
>> (or both) which will give the same results, but that's not what i'm
>> looking for.
>>
>> What i'm looking for is the paintEvent alternative for Scene Graph. I
>> have "updatePaintNode" re-implemented and am drawing stuff in a
>> component, but how can i update it when the next frame is requested? I
>> don't know if i should use a timer, do i? Doesn't Scene Graph work
>> with vsync and shouldn't i be doing something with that? If so, how?
>
> You can call update() on the item to mark the item as needing to call
> updatePaintNode again in the next frame. If you want to update every
> single frame then you can call update() inside updatePaintNode(),
> otherwise you should create a QAbstractAnimation subclass to drive it
> using the Qt Animation framework.
>
> If I recall correctly, this is very similar to QPainter elements
> except that you can expect the scenegraph to limit updatePaintNode
> calls to the vsync rate.
>
> --
> Alan Alpert

Ahhh, just adding update() in updatePaintNode was indeed all i needed.
I wouldn't have guessed it to be this simple!
This will likely be enough for now, but if i need more animation
"power" i will go for your QAbstractAnimation option.

Thanks a lot Alan :)

Regards,
Mark



More information about the Interest mailing list