summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc9
-rw-r--r--src/corelib/kernel/qobjectdefs.h4
-rw-r--r--tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp12
3 files changed, 18 insertions, 7 deletions
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
index abb0720fe9..55622dd56b 100644
--- a/src/corelib/doc/src/objectmodel/properties.qdoc
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -160,13 +160,8 @@
Because QDate is user-defined, you must include the \c{<QDate>}
header file with the property declaration.
- For QMap, QList, and QValueList properties, the property value is
- a QVariant whose value is the entire list or map. Note that the
- Q_PROPERTY string cannot contain commas, because commas separate
- macro arguments. Therefore, you must use \c QMap as the property
- type instead of \c QMap<QString,QVariant>. For consistency, also
- use \c QList and \c QValueList instead of \c QList<QVariant> and
- \c QValueList<QVariant>.
+ For historical reasons, \a QMap and \a QList as property types
+ are synonym of \a QVariantMap and \a QVariantList.
\section1 Reading and Writing Properties with the Meta-Object System
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 4d01264906..a64f2fd2b1 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -78,7 +78,11 @@ class QString;
#define Q_CLASSINFO(name, value)
#define Q_PLUGIN_METADATA(x)
#define Q_INTERFACES(x)
+#ifdef Q_COMPILER_VARIADIC_MACROS
+#define Q_PROPERTY(...)
+#else
#define Q_PROPERTY(text)
+#endif
#define Q_PRIVATE_PROPERTY(d, text)
#define Q_REVISION(v)
#define Q_OVERRIDE(text)
diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
index a18c9eb370..4d54aa4dc8 100644
--- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
+++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
@@ -46,6 +46,7 @@ class tst_QMetaProperty : public QObject
Q_PROPERTY(int value8 READ value8)
Q_PROPERTY(int value9 READ value9 CONSTANT)
Q_PROPERTY(int value10 READ value10 FINAL)
+ Q_PROPERTY(QMap<int, int> map MEMBER map)
private slots:
void hasStdCppSet();
@@ -53,6 +54,7 @@ private slots:
void isFinal();
void gadget();
void readAndWriteWithLazyRegistration();
+ void mapProperty();
public:
enum EnumType { EnumType1 };
@@ -65,6 +67,8 @@ public:
int value8() const { return 1; }
int value9() const { return 1; }
int value10() const { return 1; }
+
+ QMap<int, int> map;
};
void tst_QMetaProperty::hasStdCppSet()
@@ -182,6 +186,14 @@ void tst_QMetaProperty::readAndWriteWithLazyRegistration()
QCOMPARE(o.property("write").value<CustomWriteObjectChild*>(), &data);
}
+void tst_QMetaProperty::mapProperty()
+{
+ map.insert(5, 9);
+ QVariant v1 = QVariant::fromValue(map);
+ QVariant v = property("map");
+ QVERIFY(v.isValid());
+ QCOMPARE(map, (v.value<QMap<int,int> >()));
+}
QTEST_MAIN(tst_QMetaProperty)
#include "tst_qmetaproperty.moc"