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. What is the most efficient way to expose a QList<int> to QML?
Forum Updated to NodeBB v4.3 + New Features

What is the most efficient way to expose a QList<int> to QML?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 231 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.
  • S Offline
    S Offline
    sandro4912
    wrote on last edited by
    #1

    I got this question asked today and would like to know what is the answer.

    Possible answers:

    1. Exposing with Q_Property

    QT docs say this about it:

    If the sequence is exposed as a Q_PROPERTY, accessing any value in the
    sequence by index will cause the sequence data to be read from the
    QObject's property, then a read to occur. Similarly, modifying any
    value in the sequence will cause the sequence data to be read, and
    then the modification will be performed and the modified sequence will
    be written back to the QObject's property.

    1. Return QList from a function which is marked Q_INVOKEABLE

    QT docs say this about it:

    If the sequence is returned from a Q_INVOKABLE function, access and
    mutation is much cheaper, as no QObject property read or write occurs;
    instead, the C++ sequence data is accessed and modified directly.

    1. Make a signal in C++ and connect it to QML slot with a javascript function

    2. Expose the QList<int> as a Singleton in QML.

    Surely answer 2 is more efficient than answer 1 but what about the other two options?

    Interestingly I tried to ask Stackoverflow and they think it is opinion based. But I think there must be for sure the fastest way or what do you say?

    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