summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp9
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp8
2 files changed, 11 insertions, 6 deletions
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 714b8c5..bd80bb6 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -5252,9 +5252,12 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
#ifndef QT_NO_COMBOBOX
if (qobject_cast<const QComboBox *>(w)) {
QAbstractItemView *view = qFindChild<QAbstractItemView *>(w);
- QRenderRule subRule = renderRule(view, PseudoElement_None);
- if (subRule.hasBox() || !subRule.hasNativeBorder())
- return QFrame::NoFrame;
+ if (view) {
+ view->ensurePolished();
+ QRenderRule subRule = renderRule(view, PseudoElement_None);
+ if (subRule.hasBox() || !subRule.hasNativeBorder())
+ return QFrame::NoFrame;
+ }
}
#endif // QT_NO_COMBOBOX
break;
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 2fff6d0..816b2e8 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -2171,7 +2171,7 @@ void tst_QComboBox::noScrollbar_data()
QTest::newRow("everything and more") << QString::fromLatin1("QAbstractItemView { border: 1px 3px 5px 1px solid blue; "
" padding: 2px 5px 3px 1px; margin: 2px 5px 3px 1px; } "
" QAbstractItemView::item { border: 2px solid green; "
- " padding: 1px 1px 2px 2px margin: 1px; } " );
+ " padding: 1px 1px 2px 2px; margin: 1px; } " );
}
void tst_QComboBox::noScrollbar()
@@ -2179,10 +2179,11 @@ void tst_QComboBox::noScrollbar()
QStringList initialContent;
initialContent << "foo" << "bar" << "foobar" << "moo";
QFETCH(QString, stylesheet);
+ QString oldCss = qApp->styleSheet();
+ qApp->setStyleSheet(stylesheet);
{
QComboBox comboBox;
- comboBox.setStyleSheet(stylesheet);
comboBox.addItems(initialContent);
comboBox.show();
comboBox.resize(200, comboBox.height());
@@ -2196,7 +2197,6 @@ void tst_QComboBox::noScrollbar()
{
QTableWidget *table = new QTableWidget(2,2);
QComboBox comboBox;
- comboBox.setStyleSheet(stylesheet);
comboBox.setView(table);
comboBox.setModel(table->model());
comboBox.show();
@@ -2207,6 +2207,8 @@ void tst_QComboBox::noScrollbar()
QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
}
+
+ qApp->setStyleSheet(oldCss);
}
void tst_QComboBox::setItemDelegate()