Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Setting Material to Dark Theme inside app



  • Hi,

    my application uses the material style, in my main.qml I have this:

    Material.accent: Style.primaryColorTint1
    Material.primary: Style.primaryColorTint3
    Material.theme: Material.Light
    
    function setDarkTheme() {
        console.log('called')
        Material.theme=Material.dark
        Material.primary=Style.primaryTint1
        Material.accent=Style.primaryTint3
    }
    

    However, calling setDarkTheme (through a button which is not included in the above code snippet) does not have any effect. How can I then switch to the dark style?



  • It was merely a typo, actually it is working fine:

    Material.accent: Style.primaryColorTint1
    Material.primary: Style.primarColorTint3
    Material.theme: Material.Light
    
    function setDarkTheme() {
        console.log('called')
        Material.theme=Material.Dark
        Material.accent=Style.primaryColorTint3
        Material.primary=Style.primaryColorTint1
    }
    function setLightTheme() {
        console.log('called')
        Material.theme=Material.Light
        Material.accent=Style.primaryColorTint1
        Material.primary=Style.primaryColorTint3
    }
    

Log in to reply