Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Setting Material to Dark Theme inside app
Forum Update on Monday, May 27th 2025

Setting Material to Dark Theme inside app

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 306 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maxwell31
      wrote on last edited by
      #2

      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
      }
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved