How to implement "property value write interceptors"?



  • Hi Community!

    I would like to implement a custom property animation like the QML "Behavior" object. (Behavior on <property> {Animation{}} ).. The goal is to implement a PropertyAnimation with customizable frame rate to increase performance. Therefore i need a mechanism as described in the QtDocumentation: "http://qt-project.org/doc/qt-5/qtqml-cppintegration-definetypes.html#property-modifier-types":http://qt-project.org/doc/qt-5/qtqml-cppintegration-definetypes.html#property-modifier-types

    But it is nowhere explained how to implement that. I need a way to receive and intercept a modified Property in my C++ implementation subclassed from QQmlPropertyValueSource.

    So, can anybody provide a small example / guideline about this issue?

    Thank you very much in advance!
    Frime



  • I've never do that ... but from the documentation seems not possibile:
    [quote]Clients can register their own property value source types, but currently not property value write interceptors.[/quote]



  • Hi!

    Thanks for your answer..But I think it should be possible, because "Behavior" object does the job..

    If it's really not possible: Are there any other proposals how to reduce the frame rate of animations?

    Thanks again,
    Frime



  • "Behavior" is something built-in into Qt. What I guessed from documentation is that it's not possible to extend from a user. So, it's something not pluggable.

    However, changing topic on frame rate ... what do you exactly mean about 'frame rate of animations' ?
    Because, from what I know there is no such concept into the Animation framework. An animation is based on a timeline. It does something in a certain amount of time. So, it's does not depend on the frame rate on which the application runs.
    So, if the animation dictates that a property has to pass from 1.0 to 2.0 into 5 seconds, this happens either the app runs at 25 frame per seconds either the app runs at 50 frame per seconds.

    So, it's not clear to me what you want to achieve.



  • Hi Gianluca,

    thanks for reply! I develop a QML app running on a low-performance embedded system. Some of my custom controls (kind of speedometers) are using Property Animations. I already reimplemented the animated part directly in QMLSzenegraph (instead of QmlCanvas, like before) with much success.
    ( ~80% CPU load with QML Canvas and ~40% with QML Szenegraph). But without any animations, my App runs at 7% CPU!

    The default frame rate of QML animations is roundabout 62 FPS. This frame rate is much higher than needed for my purposes.. So why don't decrease it to save performance for backend activities? Its simply not necessary to waste CPU performance for animations, which are not needed in that quality.. 30 FPS are absolutely sufficient. And I assume that the CPU Load scales linear to the frame rate.. That's all (;



  • Hummm.. from what I know the update of Animations are synced with the refresh of the screen.
    And I don't know if there is a way to tell to Qt QML application to change it's refresh interval.
    I think that you can solve your problem if you can slow down the global refresh of the QML app. (but I don't know if Qt has an api for that).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.