}
if (propagate) {
- for (int i = 0; i < children.size(); ++i) {
- QWidget *c = qobject_cast<QWidget*>(children.at(i));
+ // We copy the list because the order may be modified
+ const QObjectList childrenList = children;
+ for (int i = 0; i < childrenList.size(); ++i) {
+ QWidget *c = qobject_cast<QWidget*>(childrenList.at(i));
if (c)
c->d_func()->inheritStyle();
}
#include <qtableview.h>
#include <qtreewidget.h>
#include <qabstractnativeeventfilter.h>
-
+#include <qproxystyle.h>
#include <QtWidgets/QGraphicsView>
#include <QtWidgets/QGraphicsProxyWidget>
void touchEventSynthesizedMouseEvent();
+ void styleSheetPropagation();
private:
bool ensureScreenSize(int width, int height);
QWidget *testWidget;
}
}
+void tst_QWidget::styleSheetPropagation()
+{
+ QTableView tw;
+ tw.setStyleSheet("background-color: red;");
+ foreach (QObject *child, tw.children()) {
+ if (QWidget *w = qobject_cast<QWidget *>(child))
+ QCOMPARE(w->style(), tw.style());
+ }
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"