diff --git a/src/platformtheme/kdeplatformtheme.h b/src/platformtheme/kdeplatformtheme.h --- a/src/platformtheme/kdeplatformtheme.h +++ b/src/platformtheme/kdeplatformtheme.h @@ -71,6 +71,7 @@ private: void loadSettings(); + void setQtQuickControlsTheme(); static void setWindowProperty(QWindow *window, const QByteArray &name, const QByteArray &value); diff --git a/src/platformtheme/kdeplatformtheme.cpp b/src/platformtheme/kdeplatformtheme.cpp --- a/src/platformtheme/kdeplatformtheme.cpp +++ b/src/platformtheme/kdeplatformtheme.cpp @@ -96,6 +96,7 @@ #endif QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, false); + setQtQuickControlsTheme(); } KdePlatformTheme::~KdePlatformTheme() @@ -390,4 +391,18 @@ } #endif +//force QtQuickControls2 to use the desktop theme as default +void KdePlatformTheme::setQtQuickControlsTheme() +{ + //if the user has explicitly set something else, don't meddle + if (qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE")) { + return; + } + //if the user is running only a QGuiApplication. Abort as this style is all about QWidgets and we know setting this will make it crash + if (!qobject_cast(qApp)) { + return; + } + qputenv("QT_QUICK_CONTROLS_STYLE", "org.kde.desktop"); +} + #include "kdeplatformtheme.moc"