diff options
author | J-P Nurmi <jpnurmi@gmail.com> | 2009-09-30 18:18:23 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-12-03 09:36:54 (GMT) |
commit | 3f18623dd8f26857d9af032c41095818f5346910 (patch) | |
tree | 35efdb96b3b7794e949c2d7af7004e665238e29f /tests/auto/qgraphicswidget | |
parent | b93000823d11575b6c30490ea97a2649a0119f86 (diff) | |
download | Qt-3f18623dd8f26857d9af032c41095818f5346910.zip Qt-3f18623dd8f26857d9af032c41095818f5346910.tar.gz Qt-3f18623dd8f26857d9af032c41095818f5346910.tar.bz2 |
Added QGraphicsWidget::autoFillBackground property.
This add a property to QGraphicsWidget to fill its
background. QWidget has the same.
Merge-Request: 1656
Reviewed-by: Alexis Menard <alexis.menard@nokia.com>
Diffstat (limited to 'tests/auto/qgraphicswidget')
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 3303df5..47e21b8 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -163,6 +163,7 @@ private slots: void addChildInpolishEvent(); void polishEvent(); void polishEvent2(); + void autoFillBackground(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2855,6 +2856,32 @@ void tst_QGraphicsWidget::polishEvent2() QVERIFY(widget->events.contains(QEvent::Polish)); } +void tst_QGraphicsWidget::autoFillBackground() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QCOMPARE(widget->autoFillBackground(), false); + widget->setAutoFillBackground(true); + QCOMPARE(widget->autoFillBackground(), true); + + const QColor color(Qt::red); + const QRect rect(0, 0, 1, 1); + + QGraphicsScene scene; + scene.addItem(widget); + widget->setGeometry(rect); + + QPalette palette = widget->palette(); + palette.setColor(QPalette::Window, color); + widget->setPalette(palette); + + QImage image(rect.size(), QImage::Format_RGB32); + QPainter painter; + painter.begin(&image); + scene.render(&painter, rect, rect); + painter.end(); + QCOMPARE(image.pixel(0, 0), color.rgb()); +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" |