Hi all,
I’m trying to get my head around this and after much research and testing I feel I must be missing something simple.
I have a QQmlPropertyMap derived object that I am adding to in my C++ code. I am then binding to the data in my QML – this is all working great. When I update the value on the C++ side my UI also updates.
C++ side:
// Set the 'runtime' Context Property, this is my QQmlPropertyMap derived object
Runtime rt;
rt.GetData()->insert("abc", 120);
rt.GetData()->insert("xyz", 65);
view.rootContext()->setContextProperty("runtime", &rt);
// Set the 'runtime' Context Property, this is my QQmlPropertyMap derived object
Runtime rt;
rt.GetData()->insert("abc", 120);
rt.GetData()->insert("xyz", 65);
view.rootContext()->setContextProperty("runtime", &rt);
To copy to clipboard, switch view to plain text mode
QML side:
MyQmlObject
{
value: runtime.data.abc
}
MyQmlObject
{
value: runtime.data.abc
}
To copy to clipboard, switch view to plain text mode
This next part is where I’m getting stuck/confused.. I want to have a QML table that displays all the key/values in the property map and automatically updates. How do I go about this? I cant find any examples that use the QQmlPropertyMap as a model for a TableView or any other view.
TableView
{
anchors.fill: parent
model: runtime.model // ????
}
TableView
{
anchors.fill: parent
model: runtime.model // ????
}
To copy to clipboard, switch view to plain text mode
Surely there must be a simple way I’m not aware of? How can I use a QQmlPropertyMap as the model for the QML TableView?
Thanks
Bookmarks