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.
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
}
}
精彩评论