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. How to expose QMap to QML

How to expose QMap to QML

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 4.8k 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.
  • H Offline
    H Offline
    Hachaso
    wrote on last edited by
    #1

    Hi!

    I have a QMap<QString, QObject*> that I would like to expose to the QML somehow.
    How can this be done?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      akrynski
      wrote on last edited by
      #2

      I think you should write your own class that inherits from QMap and than register it with
      qmlRegisterType<yourQMapClass_as_class>("yourMap_as_library", 1,0, "YourMap_as_type");

      and then simply include library into qml file with "import yourMap_as_library 1.0"
      and use it:
      YourMap_as_type{
      id: map
      ...}

      --
      Pozdrawiam i do następnego...
      Greetings and till next...

      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