[Solved] 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....
[EDIT: code formatting, please wrap in @-tags, Volker]
-
-
hi. I'm newbie
I've just do what you tell (use QLM timer)
But can you help me? I want to stop increasing the value of the text when i realease the button ?
here is my code:
@
Rectangle
{id: screen
width: 360
height: 360Text
{ id: chu
x: 155
y: 142
text: "1"
font.pointSize: 40
}Rectangle
{id: button
x: 229 y: 222 width: 100 height: 100 color: "#be3f3f" radius: 20 border.width: 3 border.color: "#111010" states:
[
State
{
name: "State1" when: MouseArea.pressed PropertyChanges
{
target: button
color: "#6dbe3e"} } ] Text
{
id: name x: 24 y: 41 text: "up" anchors.rightMargin: -23 anchors.bottomMargin: -41 anchors.leftMargin: 24 anchors.topMargin: 41 wrapMode: Text.WordWrap anchors.fill: parent font.pointSize: 11 } MouseArea
{
id: chuot
anchors.fill: parentonClicked:
{
++chu.text;
time.start()
}}
}
Item {
Timer
{id: timeinterval: 100; running: false; repeat: true onTriggered: chu.text++ }
}
}@
-
@njeisecke : i've tried start the timer using the onclicked signal handler, stop it in onReleased
and your lesson is so good.thank you very much njeisecke. I've tried it all day. Thank you.
I'm from Vietnam and want to learn about Qt to write some ap for my Nokia 5800 phone. Nice to meet you all. Sorry for my bad English. ^_^