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 C++ types correspond to QML types?

What C++ types correspond to QML types?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 966 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
    SteveG
    wrote on last edited by
    #1

    To what C++ types do the following QML types correspond? In other words, what are the appropriate C++ method parameters types or return types? Should C++ values, references or pointers be used?
    @
    {"Key1": "Value1", "Key2": "Value2"}
    @

    @
    {Key1: "Value1", Key2: "Value2"}
    @

    @
    ["Value1", "Value2"]
    @

    @
    [{"Key1": "Value1", "Key2": "Value2"}, {"Key3": "Value3", "Key4": "Value4"}]
    @

    @
    [["Value1", "Value2"], ["Value3", "Value4"]]
    @

    etc.

    Is there any documentation or examples of this?

    In addition, when are QStringList, QList, QLinkedList, QMap, etc. used? When are C++ (i.e., non-Qt) collection classes used like those in STL?

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      See "Interacting with QML Objects from C++":http://qt-project.org/doc/qt-5/qtqml-cppintegration-interactqmlfromcpp.html -- Data is passed between C++ and QML using QVariant, and it is passed by-value (no pointers or references).

      These pages might be of interest to you too:

      • "Data Type Conversion Between QML and C++":http://qt-project.org/doc/qt-5/qtqml-cppintegration-data.html
      • "Performance Considerations And Suggestions|Type Conversion":http://qt-project.org/doc/qt-5/qtquick-performance.html#type-conversion

      [quote author="SteveG" date="1403299415"]In addition, when are QStringList, QList, QLinkedList, QMap, etc. used? When are C++ (i.e., non-Qt) collection classes used like those in STL? [/quote]QML uses JavaScript types. In the examples you gave, curly braces represent JavaScript objects (stored as QMap) and square braces represent JavaScript arrays (stored as QList).

      Note: QStringList is simply a typedef of QList<QString>.

      Qt uses Qt containers, not STL containers. Also, I don't think QLinkedList is used in QML.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      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