diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2010-03-24 04:33:21 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2010-03-24 08:29:00 (GMT) |
commit | 4be83fa7337c5a4eb7b0ce085aa5854af5d33252 (patch) | |
tree | 39771d3ff7b1c2b3f64934f0e344f50cca497610 /tests | |
parent | c8fa23a5edd790d9eed0620068a29e03e4202cac (diff) | |
download | Qt-4be83fa7337c5a4eb7b0ce085aa5854af5d33252.zip Qt-4be83fa7337c5a4eb7b0ce085aa5854af5d33252.tar.gz Qt-4be83fa7337c5a4eb7b0ce085aa5854af5d33252.tar.bz2 |
Add a children private property needed for QML to support QGraphicsObject
Commit adds a private property that QML can use to add children for a given
item. This is a custom list that calls a callback which actually reparent
the item instead of just appending in the list (otherwise it will mess up
the state of QGraphicsView). This is needed because childItems() is pretty
useless you get a list but if you append something on it then it adds
that into a copy. Also the children property is the default property
a concept used by QML.
Width and Height private properties has been added in order to support
better the integration with QGraphicsWidget in QML. The actual implementation
is in the private class of QGI and QGraphicsWidget reimplements it to return
the geometry. (In 4.7 QDeclarativeItem reimplements it too).
This change should be harmless everything is private.
Task-number:QT-2757
Reviewed-by:andreas
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 0d1ad9e..5a3a54c 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -111,6 +111,8 @@ private slots: void fontPropagationSceneChange(); void geometry_data(); void geometry(); + void width(); + void height(); void getContentsMargins_data(); void getContentsMargins(); void initStyleOption_data(); @@ -775,6 +777,32 @@ void tst_QGraphicsWidget::geometry() QCOMPARE(widget.geometry(), QRectF(pos, size)); } +void tst_QGraphicsWidget::width() +{ + QGraphicsWidget w; + QCOMPARE(w.property("width").toReal(), qreal(0)); + QSignalSpy spy(&w, SIGNAL(widthChanged())); + w.setProperty("width", qreal(50)); + QCOMPARE(w.property("width").toReal(), qreal(50)); + QCOMPARE(spy.count(), 1); + //calling old school setGeometry should work too + w.setGeometry(0, 0, 200, 200); + QCOMPARE(spy.count(), 2); +} + +void tst_QGraphicsWidget::height() +{ + QGraphicsWidget w; + QCOMPARE(w.property("height").toReal(), qreal(0)); + QSignalSpy spy(&w, SIGNAL(heightChanged())); + w.setProperty("height", qreal(50)); + QCOMPARE(w.property("height").toReal(), qreal(50)); + QCOMPARE(spy.count(), 1); + //calling old school setGeometry should work too + w.setGeometry(0, 0, 200, 200); + QCOMPARE(spy.count(), 2); +} + void tst_QGraphicsWidget::getContentsMargins_data() { QTest::addColumn<qreal>("left"); |