Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-89610

Can't set property change handler on bindable properties without setter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2: Important P2: Important
    • None
    • 6.0.0
    • None
    • Fedora 33

      If there is a bindable Q_PROPERTY without WRITE attribute, like this:

      class Foo : public QObject {
          Q_OBJECT
          QML_ELEMENT
          Q_PROPERTY(int count READ count BINDABLE countBindable)
      public:
          int count() const { return mCount; }
          QBindable<int> countBindable() { return &mCount; }
      
      private:
          Q_OBJECT_BINDABLE_PROPERTY(Foo, int, mCount, nullptr)
      };

      Then setting a change handler on it in QML:

      Foo {
          onCountChanged: console.info("count changed")
      }
      

      Will result in following error:

      qrc:/main.qml:50:25: Invalid property assignment: "count" is a read-only property
      

      This looks like a bug, since not having a setter shouldn't be prevent property from being observable.

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            equeim Alexey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes