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. Construct QQmlListProperty from QList<MyClass>
Forum Updated to NodeBB v4.3 + New Features

Construct QQmlListProperty from QList<MyClass>

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.1k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jarosda
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

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

      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