View Single Post
Posts: 479 | Thanked: 1,284 times | Joined on Jan 2012 @ Enschede, The Netherlands
#4
Code:
Rectangle {
  width: 100; height: 100
  color: "green"

  Timer {
      interval: 200
      repeat: true
      id: timer
      onTriggered: counter.text = counter.count++
  }

  MouseArea {
      anchors.fill: parent
      onPressed: timer.start()
      onReleased: timer.stop()
  }
}
where the onTriggered here increases a counter (not in this snippet), but can do whatever you need it to do.

edit: it's QtQuick, so declarative all the things! I like this more:

Code:
  Timer {
      interval: 200
      repeat: true
      running: area.pressed
      onTriggered: counter.text = counter.count++
  }

  MouseArea {
      anchors.fill: parent
      id: area
  }
 

The Following 6 Users Say Thank You to Fuzzillogic For This Useful Post: