You can use a JavaScript object as a map. You cannot directly manipulate it in QML, but you can move all the code to process this object into a JavaScript file and include it as a module. Here is a simple example:
Map.js:
var _map = new Object() function value(key) { return _map[key] } function setValue(key, value) { _map[key] = value } function remove(key) { delete _map[key] } function keys() { return Object.keys(_map) } function process() { for (var key in _map) { } }
QML example:
import QtQuick 1.1 import "Map.js" as Map Item { Component.onCompleted: { Map.setValue("test", "hello") console.log("test = ", Map.value("test")) Map.remove("test", "hello") console.log("test = ", Map.value("test")) } }
The output will be:
test = hello test = undefined
source share