Construct QQmlListProperty from QList<MyClass>



  • Hi,
    I am just faced to problem how to pass args to constructor of QQmlListProperty. I tried this, but with no success:
    @
    QQmlListProperty<DataPacket>(this,
    &_dataPacketList,
    &QList<DataPacket>::append,
    &QList<DataPacket>::count,
    &QList<DataPacket>::at,
    &QList<DataPacket>::clear
    );
    @
    DataPacket is my custom class (subclassed from QObject) and _dataPacketList is instance.

    I know there is more simple constructor
    @
    QQmlListProperty::QQmlListProperty(QObject * object, QList<T *> & list)
    @
    But in docs is written:

    "Generally this constructor should not be used in production code, as a writable QList violates QML's memory management rules. However, this constructor can very useful while prototyping."

    Could you please help me how to pass pointers to QList methods?
    Thank you in advance.
    David



  • search "QQmlListProperty" inside Qt examples folder, you will get answers.


Log in to reply
 

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