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

QObjectBindableProperty does not evaluate, even if it has a signal

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.1
    • Core: Object Model
    • None

    Description

      The following code should print "Hallo", but it does not:

       

      #include <iostream>
      
      #include <QVariant>
      #include <QObject>
      #include <QProperty>
      
      class MyClass : public QObject{
          Q_OBJECT
      public:
          Q_OBJECT_BINDABLE_PROPERTY(MyClass, QVariant, foo);
      };
      
      class EagerClass : public QObject{
      Q_OBJECT
      signals:
          void mysignal();
      public:
          Q_OBJECT_BINDABLE_PROPERTY(EagerClass, QVariant, foo, &EagerClass::mysignal);
      };
      
      
      int main(){
          MyClass a;
          a.foo = 5;
      
          EagerClass follower;
          follower.foo.setBinding([&](){ return a.foo.value(); });
          QObject::connect(&follower, &EagerClass::mysignal, [](){ std::cout << "Hallo" << std::endl; });
      
          // uncomment this, then it works
          // follower.foo.value();
      
          std::cout << "should say Hallo:" << std::endl;
          a.foo = 6;
      }
      
      #include "main.moc"
      

      Attachments

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

        Activity

          People

            fabiankosmale Fabian Kosmale
            andreasbuhr Andreas Buhr
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes