Hi, I'm using QDeclarativePropertyMap in my C++ extension, and I am experiencing some binding proplems depending on the order of the items in my QML file. The following test code produces a window with the text "before.map.key1 = XXX, after.map.key4 = undefined", although the only difference between the "before" and "after" item is their relative position to the text item. Also any updates on the map work only on the "before" item. I think this is a bug, but maybe I did a mistake, that I don't see. (The problem is not, that the map property is a (QObject *) instead of a (QDeclarativePropertyMap *), or that it is CONSTANT without NOTIFY, I tried that already.)
Here is the code: ( alternatively here: http://pastebin.com/zZChEzBj ) #include <QtGui/QApplication> #include <QtDeclarative> #include <QDeclarativePropertyMap> #include "qmlapplicationviewer.h" class MyItem : public QObject { Q_OBJECT Q_PROPERTY(QStringList keys READ Keys WRITE SetKeys) Q_PROPERTY(QObject *map READ Map CONSTANT) public: MyItem(QObject *parent = 0) : QObject(parent) {} QStringList Keys() const { return map_.keys(); } QDeclarativePropertyMap *Map() { return &map_; } void SetKeys(const QStringList &keys) { Q_FOREACH(QString key, keys) { if (!map_.contains(key)) { map_.insert(key, QVariant(QString("XXX"))); } } } private: QDeclarativePropertyMap map_; }; int main(int argc, char *argv[]) { QApplication app(argc, argv); QmlApplicationViewer viewer; qmlRegisterType<MyItem>("Test", 1, 0, "MyItem"); viewer.setMainQmlFile(QLatin1String("qml/qmltest2/main.qml")); viewer.showExpanded(); return app.exec(); } #include "main.moc" ------------------------------------------------------------------------------------------- import QtQuick 1.0 import Test 1.0 Rectangle { width: 400 height: 200 MyItem { id: before keys: ["key1", "key2", "key3"] Component.onCompleted: console.log("before item completed: " + keys) } Text { text: "before.map.key1 = " + before.map.key1 + ", after.map.key4 = " + after.map.key4 anchors.centerIn: parent } MyItem { id: after keys: ["key4", "key5", "key6"] Component.onCompleted: console.log("after item completed: " + keys) } } _______________________________________________ Qt-qml mailing list Qt-qml@qt.nokia.com http://lists.qt.nokia.com/mailman/listinfo/qt-qml