0

只要按下按钮,有谁知道如何创建一个链接到文本(数字)
并高于其值的按钮?

我试过这个:

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

但这只会增加一次价值。

4

1 回答 1

2

你需要一个计时器来完成这项工作。

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
    }
}
于 2011-06-20T13:43:40.977 回答