Reputation: 229
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
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