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. Styles not behaving as expected.
Qt 6.11 is out! See what's new in the release blog

Styles not behaving as expected.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 945 Views 2 Watching
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I've been wrestling with styles in my app, and have found some issues when running on Windows. Here's the code that sets the style:

        QString l_styleName = (platform == "android")
                                  ? "Material"
                                  : (platform == "windows")
                                        ? "Windows"
                                        : "Fusion";
        QQuickStyle::setStyle(l_styleName);
    

    What I've found through experimentation is:

    • Universal style doesn't seem to use the palette.buttonText setting for changing the color of text within Buttons
    • Basic and Fusion ignore the accent color setting when used like this:
    ApplicationWindow {
        id: mainWindow
    
        readonly property string degreeSymbol: String.fromCodePoint(0xb0)
        readonly property string bullet: String.fromCodePoint(0x2022)
        readonly property real margin: width / 32.0
        readonly property real gutter: width / 64.0
    
        property alias auxTabIndex: auxTabBar.currentIndex
    
        Component.onCompleted: {
            if (styleName === "Material") {
                Material.accent = Colors.background
            } else if (styleName === "Fusion") {
                Fusion.accent = Colors.background//Colors.primaryPurple
            } else if (styleName === "Basic") {
                Basic.accent = Colors.primaryPurple
            } else if (styleName === "Universal") {
                Universal.accent = Colors.background//Colors.primaryPurple
            } else if (styleName === "Windows") {
                Windows.accent = Colors.background//Colors.primaryPurple
            }
        }
    

    Moreover, when I set the style to "Windows," I get an error: "ReferenceError: Windows is not defined."

    It's hard to believe these are bugs in the style definitions, but I can't see what I'm doing wrong. Any ideas?

    Thanks...

    piervalliP 1 Reply Last reply
    0
    • mzimmersM mzimmers

      @piervalli I've never used that before; just tried it now. I created the file with this in it:

      [Controls]
      Style=Universal
      
      [Universal]
      Theme=Light
      Accent=Universal.Indigo
      

      And added the file to my qml.qrc. I didn't add an entry to my CMakeLists.txt file, but I'm not sure I need to, as the file appears to get loaded. I say this because I'm getting the following error:

      Universal: unknown accent value: Universal.Indigo
      

      A couple questions:

      1. is there something I need to do to use the Universal colors, to get rid of this error message?
      2. can I specify 'transparent" as my accent color?

      Thanks...

      piervalliP Offline
      piervalliP Offline
      piervalli
      wrote on last edited by piervalli
      #6

      @mzimmers

      [Universal]
      Accent=#ff0000
      Theme=System

      116b2510-e0c9-4419-b15a-5ca0aa62edac-image.png

      It accepts hex color

      But With the theme "Default" I don't see any changes

      1 Reply Last reply
      1
      • mzimmersM mzimmers

        Hi all -

        I've been wrestling with styles in my app, and have found some issues when running on Windows. Here's the code that sets the style:

            QString l_styleName = (platform == "android")
                                      ? "Material"
                                      : (platform == "windows")
                                            ? "Windows"
                                            : "Fusion";
            QQuickStyle::setStyle(l_styleName);
        

        What I've found through experimentation is:

        • Universal style doesn't seem to use the palette.buttonText setting for changing the color of text within Buttons
        • Basic and Fusion ignore the accent color setting when used like this:
        ApplicationWindow {
            id: mainWindow
        
            readonly property string degreeSymbol: String.fromCodePoint(0xb0)
            readonly property string bullet: String.fromCodePoint(0x2022)
            readonly property real margin: width / 32.0
            readonly property real gutter: width / 64.0
        
            property alias auxTabIndex: auxTabBar.currentIndex
        
            Component.onCompleted: {
                if (styleName === "Material") {
                    Material.accent = Colors.background
                } else if (styleName === "Fusion") {
                    Fusion.accent = Colors.background//Colors.primaryPurple
                } else if (styleName === "Basic") {
                    Basic.accent = Colors.primaryPurple
                } else if (styleName === "Universal") {
                    Universal.accent = Colors.background//Colors.primaryPurple
                } else if (styleName === "Windows") {
                    Windows.accent = Colors.background//Colors.primaryPurple
                }
            }
        

        Moreover, when I set the style to "Windows," I get an error: "ReferenceError: Windows is not defined."

        It's hard to believe these are bugs in the style definitions, but I can't see what I'm doing wrong. Any ideas?

        Thanks...

        piervalliP Offline
        piervalliP Offline
        piervalli
        wrote on last edited by
        #2

        @mzimmers

        Hi I have created a class in C++, So I used Material.accent = AppStyle.background

        mzimmersM 1 Reply Last reply
        0
        • piervalliP piervalli

          @mzimmers

          Hi I have created a class in C++, So I used Material.accent = AppStyle.background

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #3

          @piervalli it doesn't seem to matter what value I put in that line; it's just ignored. With Universal as my style, I get a red underbar as my accent.

          piervalliP 1 Reply Last reply
          0
          • mzimmersM mzimmers

            @piervalli it doesn't seem to matter what value I put in that line; it's just ignored. With Universal as my style, I get a red underbar as my accent.

            piervalliP Offline
            piervalliP Offline
            piervalli
            wrote on last edited by
            #4

            @mzimmers

            https://doc.qt.io/qt-5/qtquickcontrols2-configuration.html
            Have you tried with qtquickcontrols2.conf?

            mzimmersM 1 Reply Last reply
            0
            • piervalliP piervalli

              @mzimmers

              https://doc.qt.io/qt-5/qtquickcontrols2-configuration.html
              Have you tried with qtquickcontrols2.conf?

              mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #5

              @piervalli I've never used that before; just tried it now. I created the file with this in it:

              [Controls]
              Style=Universal
              
              [Universal]
              Theme=Light
              Accent=Universal.Indigo
              

              And added the file to my qml.qrc. I didn't add an entry to my CMakeLists.txt file, but I'm not sure I need to, as the file appears to get loaded. I say this because I'm getting the following error:

              Universal: unknown accent value: Universal.Indigo
              

              A couple questions:

              1. is there something I need to do to use the Universal colors, to get rid of this error message?
              2. can I specify 'transparent" as my accent color?

              Thanks...

              piervalliP 1 Reply Last reply
              0
              • mzimmersM mzimmers

                @piervalli I've never used that before; just tried it now. I created the file with this in it:

                [Controls]
                Style=Universal
                
                [Universal]
                Theme=Light
                Accent=Universal.Indigo
                

                And added the file to my qml.qrc. I didn't add an entry to my CMakeLists.txt file, but I'm not sure I need to, as the file appears to get loaded. I say this because I'm getting the following error:

                Universal: unknown accent value: Universal.Indigo
                

                A couple questions:

                1. is there something I need to do to use the Universal colors, to get rid of this error message?
                2. can I specify 'transparent" as my accent color?

                Thanks...

                piervalliP Offline
                piervalliP Offline
                piervalli
                wrote on last edited by piervalli
                #6

                @mzimmers

                [Universal]
                Accent=#ff0000
                Theme=System

                116b2510-e0c9-4419-b15a-5ca0aa62edac-image.png

                It accepts hex color

                But With the theme "Default" I don't see any changes

                1 Reply Last reply
                1
                • mzimmersM mzimmers has marked this topic as solved on

                • Login

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