summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index f56e2c3024..89794ecc1d 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -743,6 +743,7 @@ private slots:
void observerMetaCall();
void setQPRopertyBinding();
void privateQPropertyShim();
+ void readThroughBindable();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -4329,6 +4330,44 @@ void tst_Moc::privateQPropertyShim()
QCOMPARE(testObject.priv.testProperty2.value(), 42);
}
+
+class BindableOnly : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int score BINDABLE scoreBindable READ default)
+public:
+ BindableOnly(QObject *parent = nullptr)
+ : QObject(parent)
+ , m_score(4)
+ {}
+ QBindable<int> scoreBindable() { return QBindable<int>(&m_score); }
+private:
+ QProperty<int> m_score;
+};
+
+
+void tst_Moc::readThroughBindable()
+{
+ BindableOnly o;
+
+ QCOMPARE(o.scoreBindable().value(), 4);
+ QCOMPARE(o.property("score").toInt(), 4);
+ o.scoreBindable().setValue(5);
+ QCOMPARE(o.scoreBindable().value(), 5);
+ QCOMPARE(o.property("score").toInt(), 5);
+
+
+ const QMetaObject *mo = o.metaObject();
+ const int i = mo->indexOfProperty("score");
+ QVERIFY(i > 0);
+
+ QMetaProperty p = mo->property(i);
+ QCOMPARE(p.name(), "score");
+
+ QVERIFY(p.isValid());
+ QCOMPARE(p.read(&o), 5);
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS