summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsgridlayout
diff options
context:
space:
mode:
authorJohn Tapsell <john.tapsell.ext@basyskom.de>2010-11-15 11:55:13 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2010-11-15 11:55:13 (GMT)
commit1781b3c876b4e1025b2a85f4e7975c171b1a1404 (patch)
tree4b15aa0cac8d0c379fd3ce1f11e1c832f2559ca3 /tests/auto/qgraphicsgridlayout
parent604c51f1fc5c79b7fad12cda911b06b9e6e5005f (diff)
downloadQt-1781b3c876b4e1025b2a85f4e7975c171b1a1404.zip
Qt-1781b3c876b4e1025b2a85f4e7975c171b1a1404.tar.gz
Qt-1781b3c876b4e1025b2a85f4e7975c171b1a1404.tar.bz2
Change the QGraphics*Layout documentation to match the code - that the default alignment is top-left.
This includes unit tests to confirm that the alignment is top-left in a variety of different cases. Merge-request: 894 Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'tests/auto/qgraphicsgridlayout')
-rw-r--r--tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 248778f..8d1f282 100644
--- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -123,6 +123,7 @@ private slots:
void heightForWidth();
void heightForWidthWithSpanning();
void stretchAndHeightForWidth();
+ void testDefaultAlignment();
};
class RectWidget : public QGraphicsWidget
@@ -726,7 +727,7 @@ void tst_QGraphicsGridLayout::columnMaximumWidth()
QCOMPARE(layout->itemAt(0,2)->geometry(), QRectF(45, 0, 25, 25));
QCOMPARE(layout->itemAt(1,2)->geometry(), QRectF(45, 25, 25, 25));
- layout->setColumnAlignment(2, Qt::AlignCenter); //FIXME This shouldn't be needed because the documentation says that center is default
+ layout->setColumnAlignment(2, Qt::AlignCenter);
widget->resize(widget->effectiveSizeHint(Qt::MaximumSize));
layout->activate();
QCOMPARE(layout->geometry(), QRectF(0,0,20+50+60, 50+50));
@@ -2859,7 +2860,6 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning()
QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 10000));
}
-
void tst_QGraphicsGridLayout::stretchAndHeightForWidth()
{
QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window);
@@ -2919,7 +2919,48 @@ void tst_QGraphicsGridLayout::stretchAndHeightForWidth()
}
+void tst_QGraphicsGridLayout::testDefaultAlignment()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsGridLayout *layout = new QGraphicsGridLayout(widget);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+
+ QGraphicsWidget *w = new QGraphicsWidget;
+ w->setMinimumSize(50,50);
+ w->setMaximumSize(50,50);
+ layout->addItem(w,0,0);
+
+ //Default alignment should be to the top-left
+ //First, check by forcing the layout to be bigger
+ layout->setMinimumSize(100,100);
+ layout->activate();
+ QCOMPARE(layout->geometry(), QRectF(0,0,100,100));
+ QCOMPARE(w->geometry(), QRectF(0,0,50,50));
+ layout->setMinimumSize(-1,-1);
+
+ //Second, check by forcing the column and row to be bigger instead
+ layout->setColumnMinimumWidth(0, 100);
+ layout->setRowMinimumHeight(0, 100);
+ layout->activate();
+ QCOMPARE(layout->geometry(), QRectF(0,0,100,100));
+ QCOMPARE(w->geometry(), QRectF(0,0,50,50));
+ layout->setMinimumSize(-1,-1);
+ layout->setColumnMinimumWidth(0, 0);
+ layout->setRowMinimumHeight(0, 0);
+
+
+ //Third, check by adding a larger item in the column
+ QGraphicsWidget *w2 = new QGraphicsWidget;
+ w2->setMinimumSize(100,100);
+ w2->setMaximumSize(100,100);
+ layout->addItem(w2,1,0);
+ layout->activate();
+ QCOMPARE(layout->geometry(), QRectF(0,0,100,150));
+ QCOMPARE(w->geometry(), QRectF(0,0,50,50));
+ QCOMPARE(w2->geometry(), QRectF(0,50,100,100));
+}
QTEST_MAIN(tst_QGraphicsGridLayout)
#include "tst_qgraphicsgridlayout.moc"