[Interest] Creating a custom QML style with Material as a fallback, but with a dark theme

Matthew Fincham matthewf at cat.co.za
Mon Sep 18 12:52:39 CEST 2023


Hi

I am attempting to create a custom QML style using this documentation: 
https://doc.qt.io/qt-6/qtquickcontrols-customize.html#definition-of-a-style

I won't provide sample code because it is close to line-for-line. The 
custom style works - there is a custom button and the other controls use 
the Material style. However, I can't get the Material style to run with 
the Dark theme.

The theme is set with an environment variable:

QT_QUICK_CONTROLS_MATERIAL_THEME=Dark

The style is set in C++:

QQuickStyle::setStyle("MyStyle");

If the style is "Material" this works as expected. With 'MyStyle', that 
falls back to Material, a Light theme is used. Is there any was to force 
the fallback style to use the Dark theme?

Many thanks
Matthew Fincham


More information about the Interest mailing list