Skip to content

Commit

Permalink
Styles example: Use system style per Default
Browse files Browse the repository at this point in the history
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ö <[email protected]>
  • Loading branch information
FriedemannKleint committed Nov 25, 2019
1 parent b8cf3c3 commit 9a82a29
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/widgets/widgets/styles/widgetgallery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include <QRadioButton>
#include <QScrollBar>
#include <QSpinBox>
#include <QStyle>
#include <QStyleFactory>
#include <QTableWidget>
#include <QTextEdit>
Expand All @@ -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);
Expand Down Expand Up @@ -134,7 +143,6 @@ WidgetGallery::WidgetGallery(QWidget *parent)
setLayout(mainLayout);

setWindowTitle(tr("Styles"));
changeStyle("NorwegianWood");
}
//! [4]

Expand Down

0 comments on commit 9a82a29

Please sign in to comment.