Hi, since nobody answered, I filed a bug now: https://bugreports.qt-project.org/browse/QTBUG-24495
Regards Sven On 14.02.2012 14:49, Sven Anderson wrote: > 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 -- Dr. Sven Anderson |-- Software Development --| snom technology AG tel: +49 30 39833 - 451 fax: +49 30 39833 - 111 ________________________________ * Join our Partner program: http://www.snom.com/partner<http://www.snom.com/partners> * Subscribe to our snom support RSS Feed<http://wiki.snom.com/wiki/index.php?title=RSS&action=feed&feed=rss> and get first-hand technical news about snom products, e.g. Firmware updates, FAQ updates, troubleshooting hints, etc. Follow us on Facebook<http://www.facebook.com/snom.VoIP.phones>, Twitter<http://twitter.com/snom>, YouTube<http://www.youtube.com/user/snomvoip>, Linkedin<http://www.linkedin.com/groups?gid=1773766> Sitz/Domicile: Charlottenstr. 68-71, 10117 Berlin, Germany Handelsregistereintrag/Register of Corporations entry: Berlin-Charlottenburg HRB 61842 B Vorstand/Executive Board: Dr. Christian Stredicke, Dr. Michael Knieling, Alexander Khan Vorsitzender des Aufsichtsrates/Chairman of the Supervisory Board: Stefan Friese snom technology AG<http://www.snom.com> _______________________________________________ Qt-qml mailing list Qt-qml@qt.nokia.com http://lists.qt.nokia.com/mailman/listinfo/qt-qml