Let's say I have a QtObject
, which has some properties. Are there any drawbacks using a binding in an other binding in the same QtObject
:
QtObject {
// This is set by the caller
property var myObject
readonly property bool haveMyObject: myObject ? true : false
readonly property bool isSomething1: haveMyObject ? myObject.isSomething1 : false
readonly property bool isSomething2: haveMyObject ? myObject.isSomething2 : false
readonly property bool isSomething3: haveMyObject ? myObject.isSomething3 : false
readonly property bool isSomething4: haveMyObject ? myObject.isSomething4 : false
readonly property bool isSomething5: haveMyObject ? myObject.isSomething5 : false
}
instead of this:
QtObject {
// This is set by the caller
property var myObject
readonly property bool haveMyObject: myObject ? true : false
readonly property bool isSomething1: myObject ? myObject.isSomething1 : false
readonly property bool isSomething2: myObject ? myObject.isSomething2 : false
readonly property bool isSomething3: myObject ? myObject.isSomething3 : false
readonly property bool isSomething4: myObject ? myObject.isSomething4 : false
readonly property bool isSomething5: myObject ? myObject.isSomething5 : false
}
Which one is preferable? The reason why I am asking is because by the Qt docs the order of evaluation is undefined.
It is not true that the order is fully undefined. The bindings are evaluated in an order defined by their dependency relationships. For any dependant-dependency
pair, it is guaranteed that the dependency
side is evaluated before dependant
. Thus, every isSomething
property is evaluated/updated after it dependency haveMyObject
has been evaluated/updated.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments