summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2010-08-12 12:31:24 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2010-08-12 13:04:26 (GMT)
commit3ee89bc0830f69d44f272eff5a0c886bff33c92e (patch)
treef514173bd885a582432cde8c9d1a9c3c75287f0a
parentd32127afb9b1ec49d4dc5cc672eaea11ebe56b72 (diff)
downloadQt-3ee89bc0830f69d44f272eff5a0c886bff33c92e.zip
Qt-3ee89bc0830f69d44f272eff5a0c886bff33c92e.tar.gz
Qt-3ee89bc0830f69d44f272eff5a0c886bff33c92e.tar.bz2
Properly emit geometryChanged() when the position change.
Also emit the signal at the very end, so people can rely on the resize event to adjust some stuff in their item. Reviewed-by:yoann
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp3
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp20
2 files changed, 21 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index c486c45..0fabd18 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -385,12 +385,12 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
if (wd->inSetPos) {
//set the new pos
d->geom.moveTopLeft(pos());
+ emit geometryChanged();
return;
}
}
QSizeF oldSize = size();
QGraphicsLayoutItem::setGeometry(newGeom);
- emit geometryChanged();
// Send resize event
bool resized = newGeom.size() != oldSize;
if (resized) {
@@ -403,6 +403,7 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
emit heightChanged();
QApplication::sendEvent(this, &re);
}
+ emit geometryChanged();
}
/*!
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index a771332..bda22eb 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -111,6 +111,7 @@ private slots:
void fontPropagationSceneChange();
void geometry_data();
void geometry();
+ void geometryChanged();
void width();
void height();
void getContentsMargins_data();
@@ -776,11 +777,28 @@ void tst_QGraphicsWidget::geometry()
QFETCH(QSizeF, size);
widget.setPos(pos);
widget.resize(size);
- if (!size.isNull())
+ if (!size.isNull() && !pos.isNull())
+ QCOMPARE(spy.count(), 2);
+ if (!size.isNull() && pos.isNull())
QCOMPARE(spy.count(), 1);
QCOMPARE(widget.geometry(), QRectF(pos, size));
}
+void tst_QGraphicsWidget::geometryChanged()
+{
+ QGraphicsWidget w;
+ w.setGeometry(0, 0, 200, 200);
+ QCOMPARE(w.geometry(), QRectF(0, 0, 200, 200));
+ QSignalSpy spy(&w, SIGNAL(geometryChanged()));
+ w.setGeometry(0, 0, 100, 100);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(w.geometry(), QRectF(0, 0, 100, 100));
+ w.setPos(10, 10);
+ QCOMPARE(spy.count(), 2);
+ QCOMPARE(w.geometry(), QRectF(10, 10, 100, 100));
+
+}
+
void tst_QGraphicsWidget::width()
{
QGraphicsWidget w;