summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets/styles
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-11-21 13:12:31 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-11-25 19:31:56 +0100
commit9a82a290001ff720a084f57b67663949d34d4c9a (patch)
tree593c49227b31e09caf62afb5114dfdb76bdfb0c3 /examples/widgets/widgets/styles
parentb8cf3c35002affe9f1876dd3940d75171be43f64 (diff)
Styles example: Use system style per Default
The example is useful as a gallery for widgets in which case the custom Norwegian Wood style is not primarily interesting. Change-Id: I96e304f97edeb43da6e8f572e01a768b1317722c Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'examples/widgets/widgets/styles')
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp
index fd8f0ec2d1..7e1616c6c0 100644
--- a/examples/widgets/widgets/styles/widgetgallery.cpp
+++ b/examples/widgets/widgets/styles/widgetgallery.cpp
@@ -65,6 +65,7 @@
#include <QRadioButton>
#include <QScrollBar>
#include <QSpinBox>
+#include <QStyle>
#include <QStyleFactory>
#include <QTableWidget>
#include <QTextEdit>
@@ -77,8 +78,16 @@ WidgetGallery::WidgetGallery(QWidget *parent)
originalPalette = QApplication::palette();
styleComboBox = new QComboBox;
- styleComboBox->addItem("NorwegianWood");
- styleComboBox->addItems(QStyleFactory::keys());
+ const QString defaultStyleName = QApplication::style()->objectName();
+ QStringList styleNames = QStyleFactory::keys();
+ styleNames.append("NorwegianWood");
+ for (int i = 1, size = styleNames.size(); i < size; ++i) {
+ if (defaultStyleName.compare(styleNames.at(i), Qt::CaseInsensitive) == 0) {
+ styleNames.swapItemsAt(0, i);
+ break;
+ }
+ }
+ styleComboBox->addItems(styleNames);
styleLabel = new QLabel(tr("&Style:"));
styleLabel->setBuddy(styleComboBox);
@@ -134,7 +143,6 @@ WidgetGallery::WidgetGallery(QWidget *parent)
setLayout(mainLayout);
setWindowTitle(tr("Styles"));
- changeStyle("NorwegianWood");
}
//! [4]