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. Passing an Array of Objects from QML to C++
QtWS25 Last Chance

Passing an Array of Objects from QML to C++

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 477 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.
  • DuBuD Offline
    DuBuD Offline
    DuBu
    wrote on last edited by
    #1

    Hi,

    given the following QML expression:

    property int value: 0
    filters: [ { type: value1 } ]
    

    how can I implement the "filters" property in C++:

    Q_PROPERTY(... filters ...)
    

    ?

    raven-worxR 1 Reply Last reply
    0
    • DuBuD DuBu

      Hi,

      given the following QML expression:

      property int value: 0
      filters: [ { type: value1 } ]
      

      how can I implement the "filters" property in C++:

      Q_PROPERTY(... filters ...)
      

      ?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @DuBu
      https://doc.qt.io/qt-5/qqmllistproperty.html

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • DuBuD Offline
        DuBuD Offline
        DuBu
        wrote on last edited by
        #3

        Wow, that was quick! ;-)

        Ok, what should the type of QQmlListProperty be?

        Q_PROPERTY(QQmlListProperty<...> filters READ filters)
        
        raven-worxR 1 Reply Last reply
        0
        • DuBuD DuBu

          Wow, that was quick! ;-)

          Ok, what should the type of QQmlListProperty be?

          Q_PROPERTY(QQmlListProperty<...> filters READ filters)
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @DuBu said in Passing an Array of Objects from QML to C++:

          Wow, that was quick! ;-)

          yes too quick. my suggestion was for QObject derived objects.
          For your case a QVariantList should be enough? Where the contained QVariants will be of type QVariantMap when they come from QML.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • DuBuD Offline
            DuBuD Offline
            DuBu
            wrote on last edited by
            #5

            Wow, QVariantList with QVariantMap as contained variants works. Thanks a lot!

            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