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. Regarding verticle slider in Qml
Qt 6.11 is out! See what's new in the release blog

Regarding verticle slider in Qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 3.6k 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.
  • Naveen_DN Offline
    Naveen_DN Offline
    Naveen_D
    wrote on last edited by
    #1

    Hi all,
    I am using slider in my project, i have customized the slider with groove and handle, as i know by default the slider orientation is Qt.Horizontal, but when i change it to Qt.Vertical i am not able to see the customized slider, only handle i am able to see and no groove
    what changes i have to make in my code. i tried with changing the width and height of the groove but didn't get the output. but when i remove the groove part i am able to get the slider.

    Here is my code:

    import QtQuick 2.6
    import QtQuick.Window 2.2
    import QtQuick.Controls 1.4
    import QtQuick.Controls.Styles 1.4
    
    Window {
        visible: true
        width: 640
        height: 480
    
        Slider {
            id: theSlider
    
            property alias sliderWidth: theSlider.width
            property alias sliderValue: theSlider.value
    
            width:250
            maximumValue: 100
            minimumValue: 0
            value:0
            orientation: Qt.Vertical
            anchors.centerIn: parent
            updateValueWhileDragging : true
            style: SliderStyle {
                groove:  Rectangle {
                    id: grooveMainrect
                    height: 5
                    antialiasing: true
                    radius: 5
                    color: "#847878"
                    Rectangle {
                        id: groovechildrect
                        width: (parent.width * theSlider.value)/theSlider.maximumValue
                        height: parent.height
                        color: Qt.lighter("#7ea6d6", 1.2)
                        radius: parent.radius
                    }
                }
    
                handle: Rectangle {
                    id:handlemainrect
                    height: (handlechildrect.height/3)+2
                    width: (handlechildrect.width/3)+2
                    radius: handlechildrect.width/2
                    anchors.verticalCenter: parent.verticalCenter
                    color: Qt.lighter("#7ea6d6", 1.2)
                    Rectangle {
                        id: handlechildrect
                        width: 25
                        height: 25
                        anchors.centerIn: parent
                        color: "#000000"
                        radius: width/2
                        opacity: 0.5
                    }
                }
            }
        }
    }
    

    Naveen_D

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Naveen_D Always provide width and height. You are missing height.

      157

      Naveen_DN 1 Reply Last reply
      1
      • p3c0P p3c0

        @Naveen_D Always provide width and height. You are missing height.

        Naveen_DN Offline
        Naveen_DN Offline
        Naveen_D
        wrote on last edited by
        #3

        @p3c0 Ya i got that..thanks. but my slider is not starting with the minimum value, by default the handle will be at the max value.

        Naveen_D

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by p3c0
          #4

          @Naveen_D Hmm, something strange. If you give width and height to slider then its default value is set to maximum whereas if not given then it is set to minimum. Here are 2 cases:

          //Works as expected
          Item {
              width: 300
              height: 300
          
              Slider {
                  orientation: Qt.Vertical
              }
          }
          
          //This doesn't
          Item {
              width: 300
              height: 300
          
              Slider {
                  width: 200
                  height: 200
                  orientation: Qt.Vertical
              }
          }
          

          Could this be a bug @jpnurmi ?

          157

          Naveen_DN 1 Reply Last reply
          0
          • p3c0P p3c0

            @Naveen_D Hmm, something strange. If you give width and height to slider then its default value is set to maximum whereas if not given then it is set to minimum. Here are 2 cases:

            //Works as expected
            Item {
                width: 300
                height: 300
            
                Slider {
                    orientation: Qt.Vertical
                }
            }
            
            //This doesn't
            Item {
                width: 300
                height: 300
            
                Slider {
                    width: 200
                    height: 200
                    orientation: Qt.Vertical
                }
            }
            

            Could this be a bug @jpnurmi ?

            Naveen_DN Offline
            Naveen_DN Offline
            Naveen_D
            wrote on last edited by
            #5

            @p3c0 One more thing, when i am increasing the value of the slider i am seeing decrease in the slider handle position, for example, i f i give slider value as 80, the actual slider handle will be appearing at 20. what is the mistake?

            Naveen_D

            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