QML never complains about non-existent property in Binding
-
Say puppy has a property called name. If puppy is mispelled, QML will output: ReferenceError: puppu is not defined.
@
Binding { target:puppu; property:"name"; value:input.text }
@But if I mispelled "name" as "namw", QML never outputs any warning or error.
Is this a normal behavior? It makes debugging harder.
@
Binding { target:puppy; property:"namw"; value:input.text }
@ -
I've yet to run into situation when I need to use Binding, so I don't really know what are they for really.
But the way I see it dynamic behaviour will always have tradeoffs.
For example, in JS there's 2 way you can refer to a property of an object:Let b be property of a, the value b is c
@
a.b = "c";console.log(a.b); //outputs c
console.log(a["b"]); //outputs cvar x = "b";
console.log(a[x]); //outputs cconsole.log(a["no_such_property"]); //no error on runtime, outputs 'undefined'
console.log(a.no_such_property); //your js script interpretation stops here.
//further code will no longer be executed.
@I don't claim to know the internals of QML Engine, but since it's ultimately JS, then I'll say this is normal behaviour.
Welcome to JS world. Now you know why a good web inspector / JS debugger is very prized in web dev community.
-
Thanks lack! Your example about JavaScript behavior is reasonable.
I use Binding to update C++ properties automatically. In my example, puppy is actually a C++ object while input is a Qt Quick TextField. Whenever input.text changes, QML will call puppy.name's WRITE method, e.g. setName(input.text). But if name was mispelled, QML will have nothing to call and in my opinion should output a warning, just like when Qt complains about a non-existent signal/slot.