Solved Change custom color themes at runtime
-
I'm using Material style in my app. I know how to switch between themes using
qtquickcontrols2.conf
file:[Controls] Style=Material [Universal] Theme=Dark Accent=Red [Material] Theme=Dark Primary=Gray Accent=#825AA7
But let say that I want to have predefined Material's themes like: pink, green, blue. Each one has own pedefined colors for Primary, Accent etc. User should be able to change between these themes at runtime (or at least after restart). How to do this? For example this works:
ApplicationWindow { id: app visible: true Material.primary: "red"
But this doesn't:
RadioButton { text: qsTr("Red"); onClicked: {console.log("clicked"); Material.primary="red"} }
-
@Kobid
TheMaterial.primary="red"
in the button's onClicked change the primary color of the button I believe.
If you want to change it for all the descendants of your ApplicationWindow, you have to doapp.Material.primary="red"
.
Qt Quick Controls 2 styling gets inherited from the parent control. -
This post is deleted! -
@GrecKo Yep, that works!