Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Returning a QList<QGadget> from Q_INVOKABLE ?
QtWS25 Last Chance

Returning a QList<QGadget> from Q_INVOKABLE ?

Scheduled Pinned Locked Moved Solved General and Desktop
qmlc++ to qmlqinvokable
3 Posts 2 Posters 1.5k 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.
  • Z Offline
    Z Offline
    Zicandar
    wrote on 4 Jun 2019, 09:30 last edited by Zicandar 6 Apr 2019, 09:30
    #1

    Hello,
    Is it possible to return a QList (or other list type) of QGadgets from a C++ function to the calling QML?
    Normally I would expose a Q_PROPERTY holding the list, however in this case I need to return the list based on an input parameter. As far as I know this cannot be done with a Q_PROPERTY in any simply way?
    The use case is for a Repeater in QML.
    I am attempting to return a struct with some Q_PROPERTY's. The struct in question only needs to be read, and the list is there for the repeater.
    I have tried looking around for an answer, however almost all cases point to QObjects, or Q_PROPERTY's.

    Help would be much appreciated!

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 4 Jun 2019, 10:21 last edited by
      #2

      QVariantList can hold classes declared as Q_GADGET and can also be exposed to QML

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      5
      • Z Offline
        Z Offline
        Zicandar
        wrote on 4 Jun 2019, 10:54 last edited by
        #3

        Thanks, this works!

        1 Reply Last reply
        0

        1/3

        4 Jun 2019, 09:30

        • Login

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