#include int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget w; auto lay = new QGridLayout(&w); auto styleComboBox = new QComboBox; const QString defaultStyleName = QApplication::style()->objectName(); QStringList styleNames = QStyleFactory::keys(); 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); lay->addWidget(styleComboBox, 0, 1); auto cbx = new QComboBox; cbx->addItem("Auto"); cbx->addItem("Light"); cbx->addItem("Dark"); lay->addWidget(cbx, 0, 0); int row = 0; for (bool flat : {true, false}) { for (bool enabled : {true, false}) { ++row; int col = 0; { auto pb = new QPushButton(QString("Up, flat: %1, enabled: %2").arg(flat).arg(enabled)); pb->setEnabled(enabled); pb->setFlat(flat); pb->setDown(false); lay->addWidget(pb, row, col++); } { auto pb = new QPushButton(QString("Down, flat: %1, enabled: %2").arg(flat).arg(enabled)); pb->setEnabled(enabled); pb->setFlat(flat); pb->setDown(true); lay->addWidget(pb, row, col++); } { auto pb = new QPushButton(QString("Checkable + !Checked, flat: %1, enabled: %2").arg(flat).arg(enabled)); pb->setEnabled(enabled); pb->setFlat(flat); pb->setCheckable(true); pb->setChecked(false); lay->addWidget(pb, row, col++); } { auto pb = new QPushButton(QString("Checkable + Checked, flat: %1, enabled: %2").arg(flat).arg(enabled)); pb->setEnabled(enabled); pb->setFlat(flat); pb->setCheckable(true); pb->setChecked(true); lay->addWidget(pb, row, col++); } } } for (bool raise : {true, false}) { for (bool enabled : {true, false}) { ++row; int col = 0; { auto pb = new QToolButton; pb->setToolTip(QString("Up, raise: %1, enabled: %2").arg(raise).arg(enabled)); pb->setEnabled(enabled); pb->setAutoRaise(raise); pb->setDown(false); lay->addWidget(pb, row, col++); } { auto pb = new QToolButton; pb->setToolTip(QString("Down, raise: %1, enabled: %2").arg(raise).arg(enabled)); pb->setEnabled(enabled); pb->setAutoRaise(raise); pb->setDown(true); lay->addWidget(pb, row, col++); } { auto pb = new QToolButton; pb->setToolTip(QString("Checkable & !Checked, raise: %1, enabled: %2").arg(raise).arg(enabled)); pb->setEnabled(enabled); pb->setAutoRaise(raise); pb->setCheckable(true); pb->setChecked(false); lay->addWidget(pb, row, col++); } { auto pb = new QToolButton; pb->setToolTip(QString("Checkable & Checked, raise: %1, enabled: %2").arg(raise).arg(enabled)); pb->setEnabled(enabled); pb->setAutoRaise(raise); pb->setCheckable(true); pb->setChecked(true); lay->addWidget(pb, row, col++); } } } w.show(); QObject::connect(cbx, &QComboBox::currentIndexChanged, cbx, [](int index) { QGuiApplication::styleHints()->setColorScheme(static_cast(index)); }); QObject::connect(styleComboBox, &QComboBox::textActivated, styleComboBox, [&](const QString & styleName) { QApplication::setStyle(QStyleFactory::create(styleName)); }); return a.exec(); }