QQmlPropertyMap how to notify QML of updates
-
@SPlatten Do not calling insert() mean binding or clear() mean release binding? It makes sense that the value is not changed.
-
@SPlatten Read the example:
https://doc.qt.io/qt-5.15/qqmlpropertymap.htmlQQmlPropertyMap ownerData; ownerData.insert("name", QVariant(QString("John Smith"))); ==> will not trigger valueChanged, sort of like initialization ownerData.insert("phone", QVariant(QString("555-5555")));
write a small program to test it.
-
@SPlatten Read the example:
https://doc.qt.io/qt-5.15/qqmlpropertymap.htmlQQmlPropertyMap ownerData; ownerData.insert("name", QVariant(QString("John Smith"))); ==> will not trigger valueChanged, sort of like initialization ownerData.insert("phone", QVariant(QString("555-5555")));
write a small program to test it.
-
@JoeCFD , is it only the initial insert of an item that does not trigger the valueChanged signal ?
I will try this out tomorrow, thank you.
-
@SPlatten I haven't followed this whole thread so apologies if I have missed something, but but regarding your most recent question, could you set your
QQmlPropertyMap
as a context property in your C++ back end? You would then be able in QML to use the name that you registered the context property as. -
Might be able to try:
Item{
Property var myData: backendQqmlPropertyMap.name
OnMyDataChanged{
// Doathing
}
}Sorry for formatting, on a phone currently!