<?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[how to emit signal with a button]]></title><description><![CDATA[<p dir="auto">this is my first time using slider and i'm learning with this exemple . i'm trying to set up a slider controlled with 3 button , i have made 3 signal to emit slider state but the probleme is the button are clickable and they send no signal to slider</p>
<pre><code>VoletCommande.qml
Item {
    id: voletCommande

    signal shutterToMove(bool value)
    signal shutterToStop()
    signal shutterToSetAt(int value) //value(0 to 100)


    property int iSliderVoletMoving : 0
    property int iSliderValue : 25


    property string textVolet : ""


    property int fontSize : 10


    width: (parent.width-10) / 3
    height: parent.height - 15





    Rectangle
    {
        anchors.fill: parent
        color: "transparent"
        border.color: "light blue"
        border.width: 0.5
        Text
         {
            text: textVolet
            anchors.top: parent.top
            anchors.topMargin: 2
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.leftMargin: 2
            color: "gray"

            font.pointSize: fontSize
         }
        Rectangle
        {
            width: parent.width
            height: parent.height*2/3 - 1.5*fontSize
            anchors.top: parent.top
            anchors.topMargin: 1.5*fontSize
            Image
            {
                id:imgVoletDown
                source: (iSliderVoletMoving == 2)? "qrc:/ShutterDownOn.png" : "qrc:/ShutterDownOff.png"
                width: parent.width / 3
                height: parent.height
                anchors.left: parent.left

                MouseArea
                {
                    anchors.fill: parent;
                    onClicked: {
                        shutterToMove(false);
                    }
                }

            }
            }
            Image
            {
                id:imgVoletStop
                source: (iSliderVoletMoving == 0) ? "qrc:/ShutterStopOn.png" :"qrc:/ShutterStopOff.png"
                width: parent.width / 3
                height: parent.height
                anchors.left: imgVoletDown.right
                MouseArea
                {
                    anchors.fill: parent;
                    onClicked: {
                        shutterToStop();
                    }

                }
             }
            Image
            {
                id:imgVoletUp
                source: (iSliderVoletMoving == 1) ? "qrc:/ShutterUpOn.png" : "qrc:/ShutterUpOff.png"
                width: parent.width / 3
                height: parent.height
                anchors.left: imgVoletStop.right

                MouseArea
                {
                    anchors.fill: parent;
                    onClicked: {
                        shutterToMove(true);


                    }
                }

            }

        }
        Rectangle
        {
            width: parent.width
            height: parent.height/3
            anchors.bottom: parent.bottom


            Slider
            {
                id : sliderVolet
                anchors.top: parent.top
                anchors.verticalCenter: parent.verticalCenter

                from: 0.0
                value: (iSliderValue / 100)
                to: parent.width * 3/4
                snapMode : Slider.SnapAlways
                stepSize : (to-from) / 20
                onMoved:
                    {
                        stutterToSetAt(100 * sliderVolet.value / sliderVolet.to);
                    }
            }
            Text {
                text: iSliderValue +"%"
                anchors.verticalCenter: parent.verticalCenter
                anchors.left : sliderVolet.right
                anchors.leftMargin: 2
                color: "light blue"

                font.pointSize: fontSize*1.2
            }
        }
}

Volet.qml

Item {
    id : voletsTab

    signal shutterToMove1(bool value) 
    signal shutterToStop1()
    signal stutterToSetAt1(int value) //value(0 to 100)

    signal shutterToMove2(bool value) // true : up, false : down
    signal shutterToStop2()
    signal stutterToSetAt2(int value) //value(0 to 100)

    signal shutterToMove3(bool value) // true : up, false : down
    signal shutterToStop3()
    signal stutterToSetAt3(int value) //value(0 to 100)

    width: parent.width
    height: parent.height
    anchors.left: parent.left
    anchors.leftMargin: 5
    anchors.top: parent.top
    anchors.topMargin: 5
    property int fontSize : 10

    property int nbOfVolets : 1

    property int iSliderVolet1Moving : 0
    property int iSliderVolet1Value : 0 // en %
    property string textVolet1 : "VR1"

    property int iSliderVolet2Moving : 0
    property int iSliderVolet2Value : 0 // en %
    property string textVolet2 : "VR2"

    property int iSliderVolet3Moving : 0
    property int iSliderVolet3Value : 0 // en %
    property string textVolet3 : "VR3"



    Rectangle
    {
        anchors.fill: parent
        color: "transparent"
        border.color: "transparent"
        border.width: 0.5
        Text
         {
            text: qsTr("VOLETS")
            anchors.top: parent.top
            anchors.topMargin: 5
            anchors.left: parent.left
            anchors.leftMargin: 5
            color: "gray"

            font.pointSize: fontSize
         }

        VoletCommande
        {
            id : voletCommande1
            textVolet : textVolet1

            iSliderVoletMoving : iSliderVolet1Moving
            iSliderValue : iSliderVolet1Value // en %

            anchors.top: parent.top
            anchors.topMargin: 15
            anchors.left: parent.left
            anchors.leftMargin: (nbOfVolets&gt;=3) ? 5 : parent.width /(nbOfVolets*3)

            onShutterToMove:{shutterToMove1(value);}
            onShutterToStop:{shutterToStop1();}
            onStutterToSetAt:{stutterToSetAt1(value);}
        }

        VoletCommande
        {
            id : voletCommande2
            textVolet : textVolet2
            iSliderVoletMoving : iSliderVolet2Moving
            iSliderValue : iSliderVolet2Value // en %

            anchors.top: parent.top
            anchors.topMargin: 15
            anchors.left: voletCommande1.right
            anchors.leftMargin: 5
            visible : (nbOfVolets&gt;=2) ? true : false

            onShutterToMove:{shutterToMove2(value);}
            onShutterToStop:{shutterToStop2();}
            onStutterToSetAt:{stutterToSetAt2(value);}
        }

        VoletCommande
        {
            id : voletCommande3
            textVolet : textVolet3
            iSliderVoletMoving : iSliderVolet3Moving
            iSliderValue : iSliderVolet3Value // en %

            anchors.top: parent.top
            anchors.topMargin: 15
            anchors.left: voletCommande2.right
            anchors.leftMargin: 5
            visible : (nbOfVolets&gt;=3) ? true : false

            onShutterToMove:{shutterToMove3(value);}
            onShutterToStop:{shutterToStop3();}
            onStutterToSetAt:{stutterToSetAt3(value);}
        }


    }
}
`Please heeelp``</code></pre>
]]></description><link>https://forum.qt.io/topic/145604/how-to-emit-signal-with-a-button</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 14:57:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/145604.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Jun 2023 19:40:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to how to emit signal with a button on Wed, 07 Jun 2023 10:06:33 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Please provide a minimal compilable example.</p>
<p dir="auto">You should cut down the amount of code between your two classes to the bare minimum to have it working first.</p>
<p dir="auto">You also seem to try to assign signals to other signals in an unrelated class.</p>
<p dir="auto">From the looks of it, you should first cleanup your VoletCommand object to work properly.</p>
<p dir="auto">Finally, boolean values to represent whether your something should move up or down is a bad idea. Use an enumeration so its explicit and you don't have to re-read your whole code to find out in which direction the thing should move.<br />
Did you also follow the <a href="https://doc.qt.io/qt-6/qtqml-syntax-signals.html" target="_blank" rel="noopener noreferrer nofollow ugc">Signal and Handler Event System docuementation</a> ?</p>
]]></description><link>https://forum.qt.io/post/760746</link><guid isPermaLink="true">https://forum.qt.io/post/760746</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 07 Jun 2023 10:06:33 GMT</pubDate></item></channel></rss>