summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorWang Chuan <ouchuanm@outlook.com>2020-10-25 21:38:19 +0800
committerWang Chuan <ouchuanm@outlook.com>2020-11-02 20:27:00 +0800
commit231be2e0a192f16141c12888e126bb2284b29b9f (patch)
tree468cea90e50fa7b1b8228a902ee2178fbaeddff2 /tests/auto/widgets
parentbe37937614c09449f83b07c4023206f2c225c31b (diff)
QCombobox: propagate the palette to the embedded line edit
Let the new created embedded QLineEdit use the palette from QCombobox, when calling [setEditable(true)] Fixes: QTBUG-81533 Pick-to: 5.15 Change-Id: Ia406dd8122a348e185f0e94d027646b95eeaa76e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 30f51e1d42..e22a900676 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -166,6 +166,7 @@ private slots:
void inputMethodUpdate();
void task_QTBUG_52027_mapCompleterIndex();
void checkMenuItemPosWhenStyleSheetIsSet();
+ void checkEmbeddedLineEditWhenStyleSheetIsSet();
private:
PlatformInputContext m_platformInputContext;
@@ -3515,5 +3516,31 @@ void tst_QComboBox::checkMenuItemPosWhenStyleSheetIsSet()
qApp->setStyleSheet(oldCss);
}
+void tst_QComboBox::checkEmbeddedLineEditWhenStyleSheetIsSet()
+{
+ QString newCss = "QWidget { background-color: red; color: white; }";
+ QString oldCss = qApp->styleSheet();
+ qApp->setStyleSheet(newCss);
+
+ QWidget topLevel;
+ auto layout = new QVBoxLayout(&topLevel);
+ topLevel.setLayout(layout);
+ auto comboBox = new QComboBox;
+ layout->addWidget(comboBox);
+ topLevel.show();
+ comboBox->setEditable(true);
+ QApplication::setActiveWindow(&topLevel);
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
+
+ QImage grab = comboBox->grab().toImage();
+ auto color = grab.pixelColor(grab.rect().center());
+
+ QVERIFY(color.red() > 240);
+ QVERIFY(color.green() < 20);
+ QVERIFY(color.blue() < 20);
+
+ qApp->setStyleSheet(oldCss);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"