[Interest] Creating a custom QML style with Material as a fallback, but with a dark theme
Matthew Fincham
matthewf at cat.co.za
Tue Sep 19 07:13:18 CEST 2023
Hi
Following up on my own post.
QQuickMaterialStyle logs a warning if an invalid theme is used (not
'Light' or 'Dark'). This is in the function that initialises the style's
global variables. (in qquickmaterialstyle.cpp)
When the 'Material' style is used as the fallback style, this log is not
seen. This initialisation function is called from the 'Material' plugin
( qtquickcontrols2materialstyleplugin.cpp), which seems to indicate the
plugin's initialisation is not run when it is the fallback theme.
Does this make sense, and is there a way to force the initialisation?
Thanks again.
Matthew Fincham
On 2023/09/18 12:52, Matthew Fincham via Interest wrote:
> 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
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
More information about the Interest
mailing list