diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h index 4d1835f178..7e3a01ef8b 100644 --- a/src/widgets/graphicsview/qgraphicsitem_p.h +++ b/src/widgets/graphicsview/qgraphicsitem_p.h @@ -318,7 +318,7 @@ public: virtual void resolvePalette(uint inheritedMask) { for (int i = 0; i < children.size(); ++i) - children.at(i)->d_ptr->resolveFont(inheritedMask); + children.at(i)->d_ptr->resolvePalette(inheritedMask); } virtual bool isProxyWidget() const; diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 1cd162e6bb..df74352e2b 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -1608,9 +1608,9 @@ void QGraphicsScenePrivate::updatePalette(const QPalette &palette) // whose parent is not a widget. foreach (QGraphicsItem *item, q->items()) { if (!item->parentItem()) { - // Resolvefont for an item is a noop operation, but + // ResolvePalette for an item is a noop operation, but // every item can be a widget, or can have a widget - // childre. + // children. item->d_ptr->resolvePalette(palette.resolve()); } } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index c89b05616d..8847a5748f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -461,6 +461,7 @@ private slots: void touchEventPropagation_data(); void touchEventPropagation(); void deviceCoordinateCache_simpleRotations(); + void resolvePaletteForItemChildren(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -11695,5 +11696,21 @@ void tst_QGraphicsItem::QTBUG_21618_untransformable_sceneTransform() QCOMPARE(item2_bottomright->deviceTransform(tx).map(QPointF()), QPointF(100, 300)); } +void tst_QGraphicsItem::resolvePaletteForItemChildren() +{ + QGraphicsScene scene; + QGraphicsRectItem item(0, 0, 50, -150); + scene.addItem(&item); + QGraphicsWidget widget; + widget.setParentItem(&item); + + QColor green(Qt::green); + QPalette paletteForScene = scene.palette(); + paletteForScene.setColor(QPalette::Active, QPalette::Window, green); + scene.setPalette(paletteForScene); + + QCOMPARE(widget.palette().color(QPalette::Active, QPalette::Window), green); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc"