<?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[Swipeable button]]></title><description><![CDATA[<p dir="auto">Hello,<br />
i wanna create a component which can slide a rectangle from left to right to simulate ON or OFF like a iOS left-to-right button to shutdown phone (<a href="https://youtu.be/qEJ5PerUqFw?t=42" target="_blank" rel="noopener noreferrer nofollow ugc">https://youtu.be/qEJ5PerUqFw?t=42</a> second 40 like this). Do you know how can I do this ?</p>
]]></description><link>https://forum.qt.io/topic/157784/swipeable-button</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 04:40:22 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/157784.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Jul 2024 11:47:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Swipeable button on Thu, 18 Jul 2024 19:54:43 GMT]]></title><description><![CDATA[<p dir="auto">That looks like a <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-switch.html" target="_blank" rel="noopener noreferrer nofollow ugc">Switch</a>.</p>
]]></description><link>https://forum.qt.io/post/805122</link><guid isPermaLink="true">https://forum.qt.io/post/805122</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Thu, 18 Jul 2024 19:54:43 GMT</pubDate></item><item><title><![CDATA[Reply to Swipeable button on Thu, 18 Jul 2024 16:10:57 GMT]]></title><description><![CDATA[<p dir="auto">I found a solution:</p>
<pre><code>import QtQuick
import QtQuick.Controls

Window {
    id: window
    visible: true
    width: 600
    height: 400
    title: "Slider test"

    Rectangle {
        id: container
        anchors.centerIn: parent
        width: 300
        height: 50
        radius: 25
        color: "lightgrey"
        border.color: "grey"
        signal myEvent(bool isOn)

        Rectangle {
            id: draggableRect
            width: 50
            height: 48
            radius: 25
            color: "orange"
            border.color: "grey"

            x: 1
            y: 1

            MouseArea {
                id: dragArea
                anchors.fill: parent
                drag.target: parent
                drag.axis: Drag.XAxis
                drag.maximumX: 250
                drag.minimumX: 0

                onReleased: {
                    if (draggableRect.x &lt; 240)
                    {
                        backAnim.running = true;
                    }
                    else
                    {
                        draggableRect.x = 250;
                        container.myEvent(true);
                    }
                }
            }

            PropertyAnimation { id: backAnim; target: draggableRect; property: "x"; to: 1; duration: 300; onFinished: container.myEvent(false); }
        }
    }


    Connections {
        target: container
        function onMyEvent(isOn) { console.log(isOn ? "ON" : "OFF"); }
    }
}
</code></pre>
<p dir="auto">reference: <a href="https://stackoverflow.com/questions/78764317/swipeable-button-in-qml/78764524?noredirect=1#comment138870538_78764524" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/78764317/swipeable-button-in-qml/78764524?noredirect=1#comment138870538_78764524</a></p>
]]></description><link>https://forum.qt.io/post/805097</link><guid isPermaLink="true">https://forum.qt.io/post/805097</guid><dc:creator><![CDATA[Bondrusiek]]></dc:creator><pubDate>Thu, 18 Jul 2024 16:10:57 GMT</pubDate></item></channel></rss>