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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Duplicate
    • Affects Version/s: 6.0.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Fedora 33

      Description

      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.

       

        Attachments

          Issue Links

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

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes