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. BusyIndicator custom colour
Forum Updated to NodeBB v4.3 + New Features

BusyIndicator custom colour

Scheduled Pinned Locked Moved Solved QML and Qt Quick
9 Posts 5 Posters 980 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.
  • B Offline
    B Offline
    Bob64
    wrote on last edited by
    #1

    I know that QML is quite flexible in terms of customisation possibilities, but it seems to me that it's also pretty poor in many ways.

    I wanted to customise the colour of the "indicator" part of the BusyIndicator for better contrast with the background I have applied. However, the only way that can be achieved is to provide a custom contentItem. In this case, the contentItem pretty much is the bulk of the BusyIndicator implementation. So, it's necessary to provide a new one just to get a different colour!

    Am I missing anything? It seems ridiculous.

    Marko StankeM 1 Reply Last reply
    0
    • B Bob64

      @mzimmers Thanks.

      I can import "normal" QtQuick.Controls and access BusyIndicator. It was just when I switched to the QtQuick.Controls.Material import as suggested that it stopped working.

      I didn't do QQuickStyle::setStyle(). I thought if you set the application style, all controls are automatically picked up from the style without the need of an explicit .Material import or whatever? As I say, I am largely baffled by styles!

      Thanks for the customisation link. I will probably follow the example there. I had in fact seen that and, in a way, it was what prompted my initial post. It involves pretty much swapping out the guts of the implementation, which is actually a C++ implementation if you look in the source, for a QML approximation that is inferior in appearance - all for the sake of changing a colour!

      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #6

      @Bob64 If you are using the Basic Style for your BusyIndicator, it uses the palette.dark color, you can change it like so:

      BusyIndicator{
          palette.dark: "pink"
      }
      

      You can see it in the code here : https://github.dev/qt/qtdeclarative/blob/1baa7fc3e7956773e6da6d062bc0f1c84a5ec3f3/src/quickcontrols/basic/BusyIndicator.qml

      B 1 Reply Last reply
      1
      • B Bob64

        I know that QML is quite flexible in terms of customisation possibilities, but it seems to me that it's also pretty poor in many ways.

        I wanted to customise the colour of the "indicator" part of the BusyIndicator for better contrast with the background I have applied. However, the only way that can be achieved is to provide a custom contentItem. In this case, the contentItem pretty much is the bulk of the BusyIndicator implementation. So, it's necessary to provide a new one just to get a different colour!

        Am I missing anything? It seems ridiculous.

        Marko StankeM Offline
        Marko StankeM Offline
        Marko Stanke
        wrote on last edited by
        #2

        @Bob64 You can use Material. After importing it and choosing a theme (optional), all you have to do is

        import QtQuick.Controls.Material
        
        BusyIndicator{
                Material.accent: "blue"
            }
        
        B 1 Reply Last reply
        0
        • Marko StankeM Marko Stanke

          @Bob64 You can use Material. After importing it and choosing a theme (optional), all you have to do is

          import QtQuick.Controls.Material
          
          BusyIndicator{
                  Material.accent: "blue"
              }
          
          B Offline
          B Offline
          Bob64
          wrote on last edited by
          #3

          @Marko-Stanke Unfortunately, that does not seem to work. It tells me that BusyIndicator is not a type. Is it possible to use individual components from a style without running that style on an application-wide basis? I have tried switching styles in the past and the UI went haywire, possibly because I have so much customisation.

          I find the whole topic of styles and theming in QML to be quite confusing. Official documentation is very sparse. I asked a question on this forum a few weeks ago about where I could find more information and there were no replies.

          mzimmersM 1 Reply Last reply
          0
          • B Bob64

            @Marko-Stanke Unfortunately, that does not seem to work. It tells me that BusyIndicator is not a type. Is it possible to use individual components from a style without running that style on an application-wide basis? I have tried switching styles in the past and the UI went haywire, possibly because I have so much customisation.

            I find the whole topic of styles and theming in QML to be quite confusing. Official documentation is very sparse. I asked a question on this forum a few weeks ago about where I could find more information and there were no replies.

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

            @Bob64 a couple things:

            1. In addition to what @Marko-Stanke wrote, you also have to use QQuickStyle::setStyle() to change your style.
            2. If Creator is telling you that BusyIndicator isn't a type, you probably didn't import QtQuick.Controls.
            3. yeah, styles are something of a black box in Qt-land (at least compared to most other things). I can tell you from recent experience that the Material 3 style is still a bit buggy. But don't blame Qt; blame Google.

            EDIT:

            You might find this helpful: customizing BusyIndicator

            B 1 Reply Last reply
            1
            • mzimmersM mzimmers

              @Bob64 a couple things:

              1. In addition to what @Marko-Stanke wrote, you also have to use QQuickStyle::setStyle() to change your style.
              2. If Creator is telling you that BusyIndicator isn't a type, you probably didn't import QtQuick.Controls.
              3. yeah, styles are something of a black box in Qt-land (at least compared to most other things). I can tell you from recent experience that the Material 3 style is still a bit buggy. But don't blame Qt; blame Google.

              EDIT:

              You might find this helpful: customizing BusyIndicator

              B Offline
              B Offline
              Bob64
              wrote on last edited by
              #5

              @mzimmers Thanks.

              I can import "normal" QtQuick.Controls and access BusyIndicator. It was just when I switched to the QtQuick.Controls.Material import as suggested that it stopped working.

              I didn't do QQuickStyle::setStyle(). I thought if you set the application style, all controls are automatically picked up from the style without the need of an explicit .Material import or whatever? As I say, I am largely baffled by styles!

              Thanks for the customisation link. I will probably follow the example there. I had in fact seen that and, in a way, it was what prompted my initial post. It involves pretty much swapping out the guts of the implementation, which is actually a C++ implementation if you look in the source, for a QML approximation that is inferior in appearance - all for the sake of changing a colour!

              GrecKoG 1 Reply Last reply
              0
              • B Bob64

                @mzimmers Thanks.

                I can import "normal" QtQuick.Controls and access BusyIndicator. It was just when I switched to the QtQuick.Controls.Material import as suggested that it stopped working.

                I didn't do QQuickStyle::setStyle(). I thought if you set the application style, all controls are automatically picked up from the style without the need of an explicit .Material import or whatever? As I say, I am largely baffled by styles!

                Thanks for the customisation link. I will probably follow the example there. I had in fact seen that and, in a way, it was what prompted my initial post. It involves pretty much swapping out the guts of the implementation, which is actually a C++ implementation if you look in the source, for a QML approximation that is inferior in appearance - all for the sake of changing a colour!

                GrecKoG Offline
                GrecKoG Offline
                GrecKo
                Qt Champions 2018
                wrote on last edited by
                #6

                @Bob64 If you are using the Basic Style for your BusyIndicator, it uses the palette.dark color, you can change it like so:

                BusyIndicator{
                    palette.dark: "pink"
                }
                

                You can see it in the code here : https://github.dev/qt/qtdeclarative/blob/1baa7fc3e7956773e6da6d062bc0f1c84a5ec3f3/src/quickcontrols/basic/BusyIndicator.qml

                B 1 Reply Last reply
                1
                • GrecKoG GrecKo

                  @Bob64 If you are using the Basic Style for your BusyIndicator, it uses the palette.dark color, you can change it like so:

                  BusyIndicator{
                      palette.dark: "pink"
                  }
                  

                  You can see it in the code here : https://github.dev/qt/qtdeclarative/blob/1baa7fc3e7956773e6da6d062bc0f1c84a5ec3f3/src/quickcontrols/basic/BusyIndicator.qml

                  B Offline
                  B Offline
                  Bob64
                  wrote on last edited by
                  #7

                  @GrecKo thanks. That looks a bit better but I don't think it is available in 5.9.6, which I am stuck on for the time being. Still useful information though as, fingers crossed, we should finally be transitioning to 5.15 very soon.

                  GrecKoG 1 Reply Last reply
                  0
                  • B Bob64

                    @GrecKo thanks. That looks a bit better but I don't think it is available in 5.9.6, which I am stuck on for the time being. Still useful information though as, fingers crossed, we should finally be transitioning to 5.15 very soon.

                    GrecKoG Offline
                    GrecKoG Offline
                    GrecKo
                    Qt Champions 2018
                    wrote on last edited by
                    #8

                    @Bob64 An other option would be to use the Colorize Graphical Effects meanwhile.

                    1 Reply Last reply
                    1
                    • B Bob64 has marked this topic as solved on
                    • J Offline
                      J Offline
                      jhayar
                      wrote on last edited by
                      #9

                      import Qt5Compat.GraphicalEffects
                      import QtQuick.Controls
                      BusyIndicator{
                      layer.enabled: true
                      layer.effect:ColorOverlay{
                      antialiasing: true
                      color: "#D8D8D8" //change it to your prefer color
                      }
                      }

                      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