<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Vertical Slider in qml]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I am trying to make changes in the below piece of code for vertical slider. How is it possible?</p>
<pre><code>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: "#bdbebf"

        Rectangle {
            width: control.visualPosition * parent.width
            height: parent.height
            color: "#21be2b"
            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"
    }
}
</code></pre>
<p dir="auto">Can anyone suggest, where to do the possible changes in this piece of code?</p>
]]></description><link>https://forum.qt.io/topic/113812/vertical-slider-in-qml</link><generator>RSS for Node</generator><lastBuildDate>Sat, 14 Nov 2026 01:58:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/113812.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 18 Apr 2020 07:31:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vertical Slider in qml on Mon, 20 Apr 2020 08:19:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qtqmllearner">@<bdi>QtQmlLearner</bdi></a></p>
<p dir="auto">Please bear in mind I am also quite new to all things QML!, so I am still learning and always will be :)</p>
<p dir="auto">The following code should answer both of your current queries. I am not sure why you would want dual purpose slider (vertical &amp; horizontal), maybe this will work for you, so here's what I came up with;</p>
<pre><code>import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4

Window {
    id: main
    visible: true
    width: 300
    height: width
    title: qsTr("Vertical &amp; Horizontal Slider")

    Rectangle {
        // serves as a rotation platform for the slider
        // click or hold in rectangle to rotate rectangle/slider
        id: rect; radius: 20
        width: 200; height: width
        color: "#11000000" // set to "#00000000" or "transparent" for transparency
        x: 50; y: 50 // sets position of rectangle in window
    }

    Slider {
        z: 1 // z axis puts slider on top of rectangle
        id: slider
        value: 0.5 // sets slider position, in this case; half way
        anchors.centerIn: parent
        style: SliderStyle {
            groove: Rectangle {
                implicitWidth: 200
                implicitHeight: 8
                color: "green"
                radius: 8
            }
            handle: Rectangle {
                anchors.centerIn: parent
                color: control.pressed ? "grey" : "lightgrey"
                border.color: "black"
                border.width: 2
                implicitWidth: 34
                implicitHeight: 34
                radius: 17 // half of implicitWidth &amp; implicitHeight to make handle round
            }
        }
    }
    MouseArea {
        anchors.fill: rect
        onClicked: {
            rect.rotation = 90 // turns rectangle 90 degrees clockwise
            slider.orientation = Qt.Horizontal // Qt.Horizontal is default for slider
            console.log("Slider is now horizontal")
        }
        onPressAndHold: {
            rect.rotation = 0 // turns rectangle back to 0 degrees
            slider.orientation = Qt.Vertical
            console.log("Slider is now vertical")
        }
    }
}

</code></pre>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/47502242-fd0d-4bf3-917d-817d282fa1e6.JPG" alt="vertical slider.JPG" class=" img-fluid img-markdown" /> <img src="https://ddgobkiprc33d.cloudfront.net/5afd557c-699e-4365-a185-98e8331380ef.JPG" alt="horizontal slider.JPG" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/589722</link><guid isPermaLink="true">https://forum.qt.io/post/589722</guid><dc:creator><![CDATA[Markkyboy]]></dc:creator><pubDate>Mon, 20 Apr 2020 08:19:52 GMT</pubDate></item><item><title><![CDATA[Reply to Vertical Slider in qml on Mon, 20 Apr 2020 06:07:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qtqmllearner">@<bdi>QtQmlLearner</bdi></a> said in <a href="/post/589674">Vertical Slider in qml</a>:</p>
<blockquote>
<p dir="auto">I want to create a slider which serve both the purpose of Vertical and horizontal.</p>
</blockquote>
<p dir="auto">Simultaneously ? No Slider.qml is not sophisticated enough for that, you'll have to grease your own form</p>
]]></description><link>https://forum.qt.io/post/589700</link><guid isPermaLink="true">https://forum.qt.io/post/589700</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Mon, 20 Apr 2020 06:07:17 GMT</pubDate></item><item><title><![CDATA[Reply to Vertical Slider in qml on Mon, 20 Apr 2020 04:34:33 GMT]]></title><description><![CDATA[<p dir="auto">Also i am not able to understand how to set x and y for background rectangle, handle rectangle?</p>
]]></description><link>https://forum.qt.io/post/589680</link><guid isPermaLink="true">https://forum.qt.io/post/589680</guid><dc:creator><![CDATA[QtQmlLearner]]></dc:creator><pubDate>Mon, 20 Apr 2020 04:34:33 GMT</pubDate></item><item><title><![CDATA[Reply to Vertical Slider in qml on Mon, 20 Apr 2020 03:43:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/markkyboy">@<bdi>Markkyboy</bdi></a></p>
<p dir="auto">I want to create a slider which serve both the purpose of Vertical and horizontal.</p>
<p dir="auto">Is it possible without the below mentioned code snippet.</p>
<pre><code> Slider {
        id: control
        value: 0.5
        orientation: Qt.Vertical
    }
</code></pre>
<p dir="auto">Any other possibility?</p>
]]></description><link>https://forum.qt.io/post/589674</link><guid isPermaLink="true">https://forum.qt.io/post/589674</guid><dc:creator><![CDATA[QtQmlLearner]]></dc:creator><pubDate>Mon, 20 Apr 2020 03:43:24 GMT</pubDate></item><item><title><![CDATA[Reply to Vertical Slider in qml on Sat, 18 Apr 2020 09:58:33 GMT]]></title><description><![CDATA[<p dir="auto">Disregarding all the extra code, you can change using 'orientation'</p>
<pre><code>    Slider {
        id: control
        value: 0.5
        orientation: Qt.Vertical
    }
}
</code></pre>
<p dir="auto">Or, with the rest of your code (crude but it works)</p>
<pre><code>    Slider {
        id: control
        value: 0.5
        rotation: 90       // &lt;--- rotation
        x: -50; y: 100     // x &amp; y position

        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: "#bdbebf"

            Rectangle {
                width: control.visualPosition * parent.width
                height: parent.height
                color: "#21be2b"
                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"
        }
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/589449</link><guid isPermaLink="true">https://forum.qt.io/post/589449</guid><dc:creator><![CDATA[Markkyboy]]></dc:creator><pubDate>Sat, 18 Apr 2020 09:58:33 GMT</pubDate></item></channel></rss>