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. Problem defining a QML type having a property being another QML type
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qtquickqmlcreate plugin
2 Posts 1 Posters 841 Views
  • 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.
  • CharbyC Offline
    CharbyC Offline
    Charby
    wrote on last edited by Charby
    #1

    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
    0
    • CharbyC Offline
      CharbyC Offline
      Charby
      wrote on last edited by
      #2

      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
      0

      • Login

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