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



  • 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 ?



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.