class Qt::Timer

Public Class Methods

every(interval, &blk) click to toggle source

Execute the given block every interval milliseconds and return a timer object. Note that if the timer is garbage collected, the block will not be executed anymore, so the caller should keep a reference to it for as long as needed. To prevent further invocations of the block, use QTimer#stop.

# File lib/rui/toolkits/qtbase/qt.rb, line 341
def self.every(interval, &blk)
  time = Qt::Time.new
  time.restart
  
  timer = new
  timer.connect(SIGNAL('timeout()')) { blk[time.elapsed] }
  timer.start(interval)
  # return the timer, so that the caller
  # has a chance to keep it referenced, so
  # that it is not garbage collected
  timer
end
in(interval, target = nil, &blk) click to toggle source

Execute the given block after interval milliseconds. If target is specified, the block is invoked in the context of target.

# File lib/rui/toolkits/qtbase/qt.rb, line 358
def self.in(interval, target = nil, &blk)
  single_shot(interval,
              Qt::BlockInvocation.new(target, blk, 'invoke()'),
              SLOT('invoke()'))
end