Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML never complains about non-existent property in Binding
Forum Updated to NodeBB v4.3 + New Features

QML never complains about non-existent property in Binding

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fxam
    wrote on last edited by
    #1

    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 }
    @

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lack
      wrote on last edited by
      #2

      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 c

      var x = "b";
      console.log(a[x]); //outputs c

      console.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.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fxam
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved