Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. change color of slider in qml

change color of slider in qml

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.4k Views 1 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.
  • V Offline
    V Offline
    vale88
    wrote on last edited by vale88
    #1

    this is my code:

    import QtQuick 2.0
    import QtQuick.Extras 1.4
    import QtQuick.Window 2.10
    import QtQuick.Controls 2.4
    import QtQuick.Controls.Styles 1.4
    
    
    Item {
    
        Slider {
            id: sliderview
            x: 207
            y: 164
            snapMode: Slider.NoSnap
            from: 1
            value: 1
            to: 100
           
            
            
           }
    
    }
    
    

    I want to change color of my slider,now color are gray and black..I want to change, I saw tutorial but they change color of groove,
    thanks

    V 1 Reply Last reply
    0
    • V vale88

      this is my code:

      import QtQuick 2.0
      import QtQuick.Extras 1.4
      import QtQuick.Window 2.10
      import QtQuick.Controls 2.4
      import QtQuick.Controls.Styles 1.4
      
      
      Item {
      
          Slider {
              id: sliderview
              x: 207
              y: 164
              snapMode: Slider.NoSnap
              from: 1
              value: 1
              to: 100
             
              
              
             }
      
      }
      
      

      I want to change color of my slider,now color are gray and black..I want to change, I saw tutorial but they change color of groove,
      thanks

      V Offline
      V Offline
      vale88
      wrote on last edited by
      #2

      @vale88 I solved:

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      
      Slider {
          id: control
          value: 0.5
      
          background: Rectangle {
              x: control.leftPadding
              y: control.topPadding + control.availableHeight / 2 - height / 2
              implicitWidth: 200
              implicitHeight: 4
              width: control.availableWidth
              height: implicitHeight
              radius: 2
              color: "#000000"
      
              Rectangle {
                  width: control.visualPosition * parent.width
                  height: parent.height
                  color: "#ffd1dc"
                  radius: 2
              }
          }
      
          handle: Rectangle {
              x: control.leftPadding + control.visualPosition * (control.availableWidth - width)
              y: control.topPadding + control.availableHeight / 2 - height / 2
              implicitWidth: 26
              implicitHeight: 26
              radius: 13
              color: control.pressed ? "#f0f0f0" : "#f6f6f6"
              border.color: "#bdbebf"
          }
      }
      
      
      Pablo J. RoginaP 1 Reply Last reply
      0
      • V vale88

        @vale88 I solved:

        import QtQuick 2.12
        import QtQuick.Controls 2.12
        
        Slider {
            id: control
            value: 0.5
        
            background: Rectangle {
                x: control.leftPadding
                y: control.topPadding + control.availableHeight / 2 - height / 2
                implicitWidth: 200
                implicitHeight: 4
                width: control.availableWidth
                height: implicitHeight
                radius: 2
                color: "#000000"
        
                Rectangle {
                    width: control.visualPosition * parent.width
                    height: parent.height
                    color: "#ffd1dc"
                    radius: 2
                }
            }
        
            handle: Rectangle {
                x: control.leftPadding + control.visualPosition * (control.availableWidth - width)
                y: control.topPadding + control.availableHeight / 2 - height / 2
                implicitWidth: 26
                implicitHeight: 26
                radius: 13
                color: control.pressed ? "#f0f0f0" : "#f6f6f6"
                border.color: "#bdbebf"
            }
        }
        
        
        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @vale88 said in change color of slider in qml:

        I solved:

        Thank you for sharing. Please don't forget to mark your post as such!

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        V 1 Reply Last reply
        0
        • Pablo J. RoginaP Pablo J. Rogina

          @vale88 said in change color of slider in qml:

          I solved:

          Thank you for sharing. Please don't forget to mark your post as such!

          V Offline
          V Offline
          vale88
          wrote on last edited by
          #4

          @Pablo-J-Rogina I marked as solved

          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