有没有人知道如何创建一个链接到文本(数字)
并超过其值的按钮,只要按下按钮?qml MouseArea for button
我想这:
Button { width:100 height:100 text: “up” onPressed: { ++myText.text; } } Text { id:myText text:1 }
但是这增加值只有一次。
有没有人知道如何创建一个链接到文本(数字)
并超过其值的按钮,只要按下按钮?qml MouseArea for button
我想这:
Button { width:100 height:100 text: “up” onPressed: { ++myText.text; } } Text { id:myText text:1 }
但是这增加值只有一次。
你需要一个计时器来完成这项工作。
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
}
}
tnx:)................. – dan
如果您设置了['Timer.triggeredOnStart'](http://doc.qt。 nokia.com/4.7-snapshot/qml-timer.html#triggeredOnStart-prop)为true,您甚至不需要重复onPressed处理程序中的增量。 :) –
你的问题并不清楚。你想让你的按钮文本保持递增,只要按下按钮? – Abhijith
yes ... exactly .. – dan