[Development] Calling a function at frame-rate before rendering

raskolnikov at es.gnu.org raskolnikov at es.gnu.org
Thu May 15 20:05:06 CEST 2014


Just for the record: I solved the problem by combining a
QAbstractAnimation and a QQuickItem. the later calls the "commit state"
function of my model in the updatePolish() override, and the animation
calls polish() on the first object on every updateCurrentTime(). This way
my state is updated and visible in the UI at frame-rate.

Thanks a lot for the hints Gunnar!


> Thank you a lot, that is a very comprenhensive response.
>> If you have GUI thread state, application logic and other stuff you can
>> call QQuickItem::polish() and reimplemnt QQuickItem::updatePolish()
>> which
>> is called just before the QML tree is synced into the render thread.
> Indeed, this is GUI thread state and this update potentially updates QML
> properties, whose state we want visible before synching to the state
> thread. This seems reasonably the best approach, but when can I call
> polish?
>> If you have continuous animations use QAbstractAnimation and use the
>> time
>> you get in updateCurrentTime().
> I did this, but then the state update seems to lag one frame behind. The
> problem looks like this:
>                                  next
> Touch Input   ->   Render  -> updateCurrentTime  ->   Render
>     \                              \
>      \                              \
>       \                              \     Depndent properties
>      Set some property                \      /  update
>         \                              \    /
>          \                              \  /
>           \                              \/
>         State update                 State update
>         Scheduled                    Comitted
> I wonder, if there is a way to commit the state before the first render,
> so dependent properties don't seem to lag. The problem with calling
> polish() explicitly is that the component that ticks the state and the
> ones that modify the state are unrelated. Maybe, is there a way to mark a
> component as always dirty needing polish?
> JP

More information about the Development mailing list