Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt 5.7: Material.accent not working
Forum Update on Monday, May 27th 2025

Qt 5.7: Material.accent not working

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 2.4k 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.
  • I Offline
    I Offline
    Ibrahim
    wrote on last edited by
    #1

    Hi; My basic code is here:

    ApplicationWindow {
      visible: true
      width: 300
      height: 300
      title: qsTr("Hello World")
    
      Material.theme: Material.Dark
      Material.accent: Material.Purple
    
      header: ToolBar {
        id: toolBar
    
        Material.accent: Material.Amber
    
        RowLayout {
          anchors.fill: parent
    
          ToolButton {
            text: qsTr("\u25C0 %1").arg(Qt.application.name)
          }
        }
      }
    }
    

    When I ran this app, I see ToolBar color is blue:
    ToolBar Color
    I tried Material.accent: Material.color(Material.Amber) and Material.background: Material.Amber but not working, always toolbar color is blue. How can I set it? Thanks.

    ekkescornerE 1 Reply Last reply
    0
    • I Ibrahim

      Hi; My basic code is here:

      ApplicationWindow {
        visible: true
        width: 300
        height: 300
        title: qsTr("Hello World")
      
        Material.theme: Material.Dark
        Material.accent: Material.Purple
      
        header: ToolBar {
          id: toolBar
      
          Material.accent: Material.Amber
      
          RowLayout {
            anchors.fill: parent
      
            ToolButton {
              text: qsTr("\u25C0 %1").arg(Qt.application.name)
            }
          }
        }
      }
      

      When I ran this app, I see ToolBar color is blue:
      ToolBar Color
      I tried Material.accent: Material.color(Material.Amber) and Material.background: Material.Amber but not working, always toolbar color is blue. How can I set it? Thanks.

      ekkescornerE Offline
      ekkescornerE Offline
      ekkescorner
      Qt Champions 2016
      wrote on last edited by
      #2

      @Ibrahim in qml you have imported QtQuick.Controls.Material 2.0 ?
      and you have configured Material style ? per ex in main.cpp:
      QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      qputenv("QT_QUICK_CONTROLS_STYLE", "material");

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.8 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

      I 1 Reply Last reply
      2
      • ekkescornerE ekkescorner

        @Ibrahim in qml you have imported QtQuick.Controls.Material 2.0 ?
        and you have configured Material style ? per ex in main.cpp:
        QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        qputenv("QT_QUICK_CONTROLS_STYLE", "material");

        I Offline
        I Offline
        Ibrahim
        wrote on last edited by
        #3

        @ekkescorner thanks. Yes, I imported QtQuick.Controls.Material 2.0 and I set QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); qputenv("QT_QUICK_CONTROLS_STYLE", "material"); in main.cpp.
        But it's not working with Material.accent. I tried Material.primary: Material.Amber and it's working well.
        Actually I don't understand, what is difference between Material.accent and Material.primary and Material.background?

        ekkescornerE 1 Reply Last reply
        0
        • I Ibrahim

          @ekkescorner thanks. Yes, I imported QtQuick.Controls.Material 2.0 and I set QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); qputenv("QT_QUICK_CONTROLS_STYLE", "material"); in main.cpp.
          But it's not working with Material.accent. I tried Material.primary: Material.Amber and it's working well.
          Actually I don't understand, what is difference between Material.accent and Material.primary and Material.background?

          ekkescornerE Offline
          ekkescornerE Offline
          ekkescorner
          Qt Champions 2016
          wrote on last edited by
          #4

          @Ibrahim you should study https://material.google.com/style/color.html# to see where accent is used and where primary is used
          and the Material.background is normaly set by Qt Quick Controls 2 and depends from Theme.
          you can overwrite the background - see here: https://doc-snapshots.qt.io/qt5-5.8/qtquickcontrols2-material.html#material-background-attached-prop

          ekke ... Qt Champion 2016 | 2024 ... mobile business apps
          5.15 --> 6.8 https://t1p.de/ekkeChecklist
          QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

          1 Reply Last reply
          2

          • Login

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