Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Problem defining a QML type having a property being another QML type

    QML and Qt Quick
    qtquick qml create plugin
    1
    2
    677
    Loading More Posts
    • 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.
    • Charby
      Charby last edited by Charby

      I would like to create a plugin that publish 2 QML types : TypeA and TypeB.
      I have created 2 QObject base class for TypeA and TypeB. The creation of the classes and plugin is running well but now I need that TypeB could have TypeA as a property (actually, TypeB is a QAbstractItemListModel base class and I would like to fill the model using methods of TypeA).

      What I have done so far...
      C++ side :

      class TypeA : public QObject
      {
          Q_OBJECT
          ...
      }
      class TypeB : public QAbstractListModel
      {
          Q_OBJECT
          Q_PROPERTY( TypeA* client READ getClient  WRITE setClient NOTIFY clientChanged)
      public:    
          TypeA* getClient() {
              return client;
          }
          void setClient(TypeA * _client){
              if (be)
                  client = _client;
          }
      signals:
          void clientChanged();
          ...
      private:
          TypeA* client = nullptr;
      }
      

      and now from the QML side :

      TypeA{
          id:myTypeA
      }
      TypeB{
         client:myTypeA
      }
      

      This is not working : setClient is never called.
      note : I have defined others properties in TypeA and TypeB (QString, bool..) which are working ok - and I haven't found warning raised by the moc compiler.
      Do you know what I am doing wrong ?

      1 Reply Last reply Reply Quote 0
      • Charby
        Charby last edited by

        Replying to myself...The problem vanished after a clean -rebuild all...Probably a MOOC'ing cache issue. Sorry for the bothering !

        1 Reply Last reply Reply Quote 0
        • First post
          Last post