Sha256: e77eebae5e192fe85c654a99a5f753016d50ebfa73c5a2e2ce6aa643286ee58d

Contents?: true

Size: 756 Bytes

Versions: 7

Compression:

Stored size: 756 Bytes

Contents

require 'Qt'

class CannonField < Qt::Widget
  signals 'angleChanged(int)'
  slots 'setAngle(int)'

  def initialize(parent = nil)
    super
    @currentAngle = 45
    setPalette(Qt::Palette.new(Qt::Color.new(250, 250, 200)))
    setAutoFillBackground(true)
  end

  def setAngle(degrees)
    if degrees < 5
      degrees = 5
    elsif degrees > 70
      degrees = 70
    end
    if @currentAngle == degrees
      return
    end
    @currentAngle = degrees
    repaint()
    emit angleChanged(@currentAngle)
  end

  def paintEvent(event)
    p = Qt::Painter.new(self)
    p.drawText(200, 200, "Angle = %d" % @currentAngle)
    p.end()
  end

  def sizePolicy()
    return Qt::SizePolicy.new(Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding)
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rock-qtbindings-4.8.6.5 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.5 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.5-x86-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.5-x64-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.4-x86-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.4-x64-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.4 examples/tutorial/t8/cannon.rb