开发者

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
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜