summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-02-08 01:00:08 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-02-08 01:00:08 +0100
commit96340555430727d4bf38b188d70e272bfc7d286e (patch)
treeb0fade390aec78601edf49f4155ebb5a0c445049 /tests/auto/widgets/widgets
parent2c189ac79b2000041bba85b21b667cedf7fffbd1 (diff)
parent75285b64ada65748f1fee3942a95b46a3f0b9d7e (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 3878e7ccb2..c934f8e27b 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -47,6 +47,7 @@
#include <qtablewidget.h>
#include <qscrollbar.h>
#include <qboxlayout.h>
+#include <qstackedwidget.h>
#include <qstandarditemmodel.h>
#include <qstringlistmodel.h>
@@ -164,6 +165,7 @@ private slots:
void task_QTBUG_56693_itemFontFromModel();
void inputMethodUpdate();
void task_QTBUG_52027_mapCompleterIndex();
+ void checkMenuItemPosWhenStyleSheetIsSet();
private:
PlatformInputContext m_platformInputContext;
@@ -3515,5 +3517,46 @@ void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex()
QCOMPARE(arguments.at(0).toInt(), 1);
}
+void tst_QComboBox::checkMenuItemPosWhenStyleSheetIsSet()
+{
+ QString newCss = "QComboBox {font-size: 18pt;}";
+ QString oldCss = qApp->styleSheet();
+ qApp->setStyleSheet(newCss);
+
+ QWidget topLevel;
+ QVBoxLayout *layout = new QVBoxLayout(&topLevel);
+ QStackedWidget *stack = new QStackedWidget(&topLevel);
+ layout->addWidget(stack);
+ QWidget *container = new QWidget(&topLevel);
+ QHBoxLayout *cLayout = new QHBoxLayout(container);
+ QComboBox *cBox = new QComboBox;
+
+ QStandardItemModel *model = new QStandardItemModel(cBox);
+ QStandardItem *item = new QStandardItem(QStringLiteral("Item1"));
+ model->appendRow(item);
+ item = new QStandardItem(QStringLiteral("Item2"));
+ model->appendRow(item);
+ item = new QStandardItem(QStringLiteral("Item3"));
+ model->appendRow(item);
+ item = new QStandardItem(QStringLiteral("Item4"));
+ model->appendRow(item);
+ cBox->setModel(model);
+
+ cLayout->addWidget(cBox);
+ stack->addWidget(container);
+ topLevel.show();
+ cBox->showPopup();
+
+ QTRY_VERIFY(cBox->view());
+ QTRY_VERIFY(cBox->view()->isVisible());
+
+ int menuHeight = cBox->view()->geometry().height();
+ QRect menuItemRect = cBox->view()->visualRect(model->indexFromItem(item));
+
+ QCOMPARE(menuHeight, menuItemRect.y() + menuItemRect.height());
+
+ qApp->setStyleSheet(oldCss);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"