O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A limitation of automatic property updates

QML does its best to determine when the function value may change, but it is not omnipotent. For our last function, it can easily determine that the function result depends on the value of the textField.text property, so it will re-evaluate the binding if that value changes. However, in some cases, it can't know that a function may return a different value the next time it is called, and in such situations, the statement will not be re-evaluated. Consider the following property binding:

Label {    function colorByTime() {        var d = new Date();        var seconds = d.getSeconds();        if(seconds < 15) return "red";        if(seconds < 30) return "green";        if(seconds < 45) return "blue";        return "purple";    } color: colorByTime() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required