Sha256: b27f703ab98bc2b92dba48a53dfcb247f5e90bdac901a66a7cded7485dfab836

Contents?: true

Size: 736 Bytes

Versions: 22

Compression:

Stored size: 736 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

22 entries across 20 versions & 2 rubygems

Version Path
qtbindings-4.8.6.2 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.1 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.0 examples/tutorial/t8/cannon.rb
qtbindings-4.8.6.0-x86-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.8.5.2 examples/tutorial/t8/cannon.rb
qtbindings-4.8.5.2-x86-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.8.5.1 examples/tutorial/t8/cannon.rb
qtbindings-4.8.5.0 examples/tutorial/t8/cannon.rb
qtbindings-4.8.3.0-x86-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.8.3.0 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.4-x86-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.4 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.3 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.2-x86-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.2 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.1 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.1-x86-mingw32 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.0 examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.0 ext/ruby/qtruby/examples/tutorial/t8/cannon.rb
qtbindings-4.6.3.0-x86-mingw32 examples/tutorial/t8/cannon.rb