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. Why the app theme did not change with the system

Why the app theme did not change with the system

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 1.7k 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.
  • D Offline
    D Offline
    Dylan Deng
    wrote on last edited by
    #1

    I have specified the Material theme as "System" in qtquickcontrols2.conf, and the current macOS theme is set to dark mode. But when I compile and re-run the application, the title bar and window contents of the application are still displayed in light mode.

    [Controls]
    Style=Material
    
    [Material]
    Primary=#41cd52
    Accent=#41cd52
    Theme=System
    

    What other settings should I make?

    M 2 Replies Last reply
    0
    • D Dylan Deng

      I have specified the Material theme as "System" in qtquickcontrols2.conf, and the current macOS theme is set to dark mode. But when I compile and re-run the application, the title bar and window contents of the application are still displayed in light mode.

      [Controls]
      Style=Material
      
      [Material]
      Primary=#41cd52
      Accent=#41cd52
      Theme=System
      

      What other settings should I make?

      M Offline
      M Offline
      MEMekaniske
      wrote on last edited by
      #2

      @Dylan-Deng

      Don't know how you could do it in qtquickcontrols2.conf, but you could do this, as described by the docs,
      Maybe specifying Universal.System in conf works too..

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      import QtQuick.Controls.Universal 2.12
      
      ApplicationWindow {
          visible: true
          Universal.theme: Universal.System
          
          Column {
              anchors.centerIn: parent
              RadioButton { text: qsTr("Small") }
              RadioButton { text: qsTr("Medium");  checked: true }
              RadioButton { text: qsTr("Large") }
          }
      }
      

      https://doc.qt.io/qt-5/qtquickcontrols2-universal.html

      1 Reply Last reply
      0
      • D Dylan Deng

        I have specified the Material theme as "System" in qtquickcontrols2.conf, and the current macOS theme is set to dark mode. But when I compile and re-run the application, the title bar and window contents of the application are still displayed in light mode.

        [Controls]
        Style=Material
        
        [Material]
        Primary=#41cd52
        Accent=#41cd52
        Theme=System
        

        What other settings should I make?

        M Offline
        M Offline
        MEMekaniske
        wrote on last edited by
        #3

        @Dylan-Deng seems like you should be able to do this;

        [Controls]
        Style=Universal

        [Universal]
        Theme=System

        1 Reply Last reply
        0
        • MarkkyboyM Offline
          MarkkyboyM Offline
          Markkyboy
          wrote on last edited by
          #4

          There is plenty of information on this subject, found with a simple search. for example;

          https://doc.qt.io/qt-5/qtquickcontrols2-configuration.html ~ this page gives some pretty detailed configurations for various themes/fonts/colours.

          Don't just sit there standing around, pick up a shovel and sweep up!

          I live by the sea, not in it.

          D 1 Reply Last reply
          0
          • MarkkyboyM Markkyboy

            There is plenty of information on this subject, found with a simple search. for example;

            https://doc.qt.io/qt-5/qtquickcontrols2-configuration.html ~ this page gives some pretty detailed configurations for various themes/fonts/colours.

            D Offline
            D Offline
            Dylan Deng
            wrote on last edited by
            #5

            @Markkyboy I spent an afternoon through google and Qt documents, which failed to achieve the program to change the theme color according to the theme set by the system.

            According to the documentation, the only thing I can see is that set Theme as System, but it does not work.

            The use of Universal.theme: Universal.System in QML files, it does not work too.

            M 1 Reply Last reply
            0
            • D Dylan Deng

              @Markkyboy I spent an afternoon through google and Qt documents, which failed to achieve the program to change the theme color according to the theme set by the system.

              According to the documentation, the only thing I can see is that set Theme as System, but it does not work.

              The use of Universal.theme: Universal.System in QML files, it does not work too.

              M Offline
              M Offline
              MEMekaniske
              wrote on last edited by
              #6

              @Dylan-Deng You have also included the universtal style when testing Universal.theme:Universal.System ?

              import QtQuick.Controls.Universal 2.12
              

              And removed every other setting related to styles?

              D 1 Reply Last reply
              0
              • M MEMekaniske

                @Dylan-Deng You have also included the universtal style when testing Universal.theme:Universal.System ?

                import QtQuick.Controls.Universal 2.12
                

                And removed every other setting related to styles?

                D Offline
                D Offline
                Dylan Deng
                wrote on last edited by Dylan Deng
                #7

                @MEMekaniske Yes, I'm using Qt example gallery and removed QQuickStyle::setStyle in mian.cpp

                QSettings settings;
                QString style = QQuickStyle::name();
                if (!style.isEmpty())
                    settings.setValue("style", style);
                else
                    QQuickStyle::setStyle(settings.value("style").toString());
                

                Then I set the qtquickcontrols2.conf like this:

                [Controls]
                Style=Material
                
                [Material]
                Primary=#41cd52
                Accent=#41cd52
                Theme=System
                

                It does not working out whether or not I set Material.theme: Material.System

                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