How to expose QMap to QML



  • Hi!

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



  • 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
    ...}


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.