dan
dan

Reputation: 229

qml MouseArea for button

Does anyone know how to create a button that is linked to Text (number)
and above its value as long as the button pressed?

i tried this:

Button { width:100 height:100 text: “up” onPressed: { ++myText.text; } } Text { id:myText text:1 }

but this increases the value only once.

Upvotes: 0

Views: 910

Answers (1)

Abhijith
Abhijith

Reputation: 2632

You need a timer for this job.

Item
{
    Button { id:button1 width:100 height:100 text: “up” onPressed: { ++myText.text; } }
    Text { id:myText text:1 } 

    Timer {
     interval: 500; running: button1.pressed ; repeat: true
     onTriggered: ++myText.text
    }
}

Upvotes: 2

Related Questions