397 |
397 |
398 view.resize(450,150); |
398 view.resize(450,150); |
399 widget->resize(widget->effectiveSizeHint(Qt::MaximumSize)); |
399 widget->resize(widget->effectiveSizeHint(Qt::MaximumSize)); |
400 view.show(); |
400 view.show(); |
401 widget->show(); |
401 widget->show(); |
402 QApplication::processEvents(); |
402 QApplication::sendPostedEvents(0, 0); |
403 // Check default |
403 // Check default |
404 QCOMPARE(layout->columnAlignment(0), 0); |
404 QCOMPARE(layout->columnAlignment(0), 0); |
405 QCOMPARE(layout->columnAlignment(1), 0); |
405 QCOMPARE(layout->columnAlignment(1), 0); |
406 QCOMPARE(layout->columnAlignment(2), 0); |
406 QCOMPARE(layout->columnAlignment(2), 0); |
407 |
407 |
412 // see if item alignment takes preference over columnAlignment |
412 // see if item alignment takes preference over columnAlignment |
413 layout->setAlignment(layout->itemAt(1,0), Qt::AlignHCenter); |
413 layout->setAlignment(layout->itemAt(1,0), Qt::AlignHCenter); |
414 layout->setAlignment(layout->itemAt(1,1), Qt::AlignRight); |
414 layout->setAlignment(layout->itemAt(1,1), Qt::AlignRight); |
415 layout->setAlignment(layout->itemAt(1,2), Qt::AlignLeft); |
415 layout->setAlignment(layout->itemAt(1,2), Qt::AlignLeft); |
416 |
416 |
417 QApplication::processEvents(); // process LayoutRequest |
417 QApplication::sendPostedEvents(0, 0); // process LayoutRequest |
418 /* |
418 /* |
419 +----------+------------+---------+ |
419 +----------+------------+---------+ |
420 | Left | HCenter | Right | |
420 | Left | HCenter | Right | |
421 +----------+------------+---------+ |
421 +----------+------------+---------+ |
422 | HCenter | Right | Left | |
422 | HCenter | Right | Left | |
844 |
844 |
845 view.resize(330,450); |
845 view.resize(330,450); |
846 widget->resize(300, 400); |
846 widget->resize(300, 400); |
847 view.show(); |
847 view.show(); |
848 widget->show(); |
848 widget->show(); |
849 QApplication::processEvents(); |
849 QApplication::sendPostedEvents(0, 0); |
850 // Check default |
850 // Check default |
851 QCOMPARE(layout->rowAlignment(0), 0); |
851 QCOMPARE(layout->rowAlignment(0), 0); |
852 QCOMPARE(layout->rowAlignment(1), 0); |
852 QCOMPARE(layout->rowAlignment(1), 0); |
853 QCOMPARE(layout->rowAlignment(2), 0); |
853 QCOMPARE(layout->rowAlignment(2), 0); |
854 |
854 |
867 // see if item alignment takes preference over rowAlignment |
867 // see if item alignment takes preference over rowAlignment |
868 layout->setAlignment(layout->itemAt(0,0), Qt::AlignRight); |
868 layout->setAlignment(layout->itemAt(0,0), Qt::AlignRight); |
869 layout->setAlignment(layout->itemAt(1,0), Qt::AlignTop); |
869 layout->setAlignment(layout->itemAt(1,0), Qt::AlignTop); |
870 layout->setAlignment(layout->itemAt(2,0), Qt::AlignHCenter); |
870 layout->setAlignment(layout->itemAt(2,0), Qt::AlignHCenter); |
871 |
871 |
872 QApplication::processEvents(); // process LayoutRequest |
872 QApplication::sendPostedEvents(0, 0); // process LayoutRequest |
873 |
873 |
874 QCOMPARE(layout->alignment(layout->itemAt(0,0)), Qt::AlignRight); //Qt::AlignRight | Qt::AlignBottom |
874 QCOMPARE(layout->alignment(layout->itemAt(0,0)), Qt::AlignRight); //Qt::AlignRight | Qt::AlignBottom |
875 QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(50, 50, 50, 50)); |
875 QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(50, 50, 50, 50)); |
876 QCOMPARE(layout->rowAlignment(0), Qt::AlignBottom); |
876 QCOMPARE(layout->rowAlignment(0), Qt::AlignBottom); |
877 QCOMPARE(layout->itemAt(0,1)->geometry(), QRectF(101, 50, 50, 50)); |
877 QCOMPARE(layout->itemAt(0,1)->geometry(), QRectF(101, 50, 50, 50)); |
1832 ItemDesc desc = itemDescriptions.at(i); |
1832 ItemDesc desc = itemDescriptions.at(i); |
1833 RectWidget *item = new RectWidget(widget); |
1833 RectWidget *item = new RectWidget(widget); |
1834 desc.apply(layout, item); |
1834 desc.apply(layout, item); |
1835 } |
1835 } |
1836 |
1836 |
1837 QApplication::processEvents(); |
1837 QApplication::sendPostedEvents(0, 0); |
1838 |
1838 |
1839 widget->show(); |
1839 widget->show(); |
1840 view.show(); |
1840 view.show(); |
1841 view.resize(400,300); |
1841 view.resize(400,300); |
1842 if (newSize.isValid()) |
1842 if (newSize.isValid()) |
1843 widget->resize(newSize); |
1843 widget->resize(newSize); |
1844 |
1844 |
1845 QApplication::processEvents(); |
1845 QApplication::sendPostedEvents(0, 0); |
1846 for (i = 0; i < expectedSizes.count(); ++i) { |
1846 for (i = 0; i < expectedSizes.count(); ++i) { |
1847 QSizeF itemSize = layout->itemAt(i)->geometry().size(); |
1847 QSizeF itemSize = layout->itemAt(i)->geometry().size(); |
1848 QCOMPARE(itemSize, expectedSizes.at(i)); |
1848 QCOMPARE(itemSize, expectedSizes.at(i)); |
1849 } |
1849 } |
1850 |
1850 |
1992 ItemDesc desc = itemDescriptions.at(i); |
1992 ItemDesc desc = itemDescriptions.at(i); |
1993 RectWidget *item = new RectWidget(widget); |
1993 RectWidget *item = new RectWidget(widget); |
1994 desc.apply(layout, item); |
1994 desc.apply(layout, item); |
1995 } |
1995 } |
1996 |
1996 |
1997 QApplication::processEvents(); |
1997 QApplication::sendPostedEvents(0, 0); |
1998 |
1998 |
1999 widget->show(); |
1999 widget->show(); |
2000 view.resize(400,300); |
2000 view.resize(400,300); |
2001 view.show(); |
2001 view.show(); |
2002 if (newSize.isValid()) |
2002 if (newSize.isValid()) |
2003 widget->resize(newSize); |
2003 widget->resize(newSize); |
2004 |
2004 |
2005 QApplication::processEvents(); |
2005 QApplication::sendPostedEvents(0, 0); |
2006 for (i = 0; i < expectedGeometries.count(); ++i) { |
2006 for (i = 0; i < expectedGeometries.count(); ++i) { |
2007 QRectF itemRect = layout->itemAt(i)->geometry(); |
2007 QRectF itemRect = layout->itemAt(i)->geometry(); |
2008 QCOMPARE(itemRect, expectedGeometries.at(i)); |
2008 QCOMPARE(itemRect, expectedGeometries.at(i)); |
2009 } |
2009 } |
2010 |
2010 |