diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-01-13 13:43:02 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-01-15 07:38:15 +0100 |
commit | b749163bb81c1a5e46ec14fa0fecdbced1a7ed85 (patch) | |
tree | 0a02361df8f3631944143a53b1dfc961b70f4574 /tests | |
parent | 02c2a80865677163efb68a9d1db3b462f16ccc3d (diff) |
Add test case for style sheet selectors for enum properties
In Qt 5, such selectors have to use the integer value of the enum
value. Using the enum value name does not work.
In Qt 6, such selectors must use the enum value by name, using
the integer does not work.
It's not clear yet what changed, possible a side effect of the
changes and improvements in the meta object system and QVariant in
Qt 6. So for now, document the difference in behavior in a test.
Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-99642
Change-Id: I96e0280b191b8ca06b16a97ab3ed367e9a8f43a0
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 272c175042..6409a669fe 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -129,6 +129,8 @@ private slots: void QTBUG36933_brokenPseudoClassLookup(); void styleSheetChangeBeforePolish(); void placeholderColor(); + void enumPropertySelector_data(); + void enumPropertySelector(); //at the end because it mess with the style. void widgetStyle(); void appStyle(); @@ -2340,6 +2342,42 @@ void tst_QStyleSheetStyle::placeholderColor() QCOMPARE(le2.palette().placeholderText(), red); } +void tst_QStyleSheetStyle::enumPropertySelector_data() +{ + QTest::addColumn<QString>("styleSheet"); + + QTest::addRow("Enum value") << R"(QToolButton[popupMode=MenuButtonPopup] { padding-right: 40px; })"; + QTest::addRow("Int value") << R"(QToolButton[popupMode="1"] { padding-right: 40px; })"; +} + +void tst_QStyleSheetStyle::enumPropertySelector() +{ + QFETCH(QString, styleSheet); + + QToolButton button; + QMenu menu; + menu.addAction("Action1"); + QPixmap pm(50, 50); + pm.fill(Qt::red); + button.setIcon(pm); + button.setMenu(&menu); + button.setPopupMode(QToolButton::MenuButtonPopup); + + button.show(); + const QSize unstyledSizeHint = button.sizeHint(); + + qApp->setStyleSheet(styleSheet); + const QSize styledSizeHint = button.sizeHint(); + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QEXPECT_FAIL("Enum value", "In Qt 5, style sheet selectors have to use integer enum values", Continue); +#else + QEXPECT_FAIL("Int value", "In Qt 6, style sheet selectors must use the enum value name", Continue); +#endif + + QVERIFY(styledSizeHint.width() > unstyledSizeHint.width()); +} + void tst_QStyleSheetStyle::iconSizes_data() { QTest::addColumn<QString>("styleSheet"); |