You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdebindings/qtruby/rubylib/examples/testcases/bugs.rb

58 lines
1.0 KiB

require 'Qt'
#### TODO ###
# dup of qobject crash
def bug1
p1 = TQt::Point.new(5,5)
p1.setX 5
p p1
p3 = p1.dup
p3.setX 5
p p3
end
#bug1
#### FIXED ###
def bug3
a = TQt::Application.new(ARGV)
@file = TQt::PopupMenu.new
@file.insertSeparator
TQt::debug_level = TQt::DebugLevel::High
p $qApp
@file.insertItem("Quit", $qApp, SLOT('quit()'))
@file.exec
end
#bug3
class CPUWaster < TQt::Widget
def initialize(*k)
super(*k)
end
def draw
painter = TQt::Painter.new(self)
0.upto(1000) { |i|
cw, ch = width, height
c = TQt::Color.new(rand(255), rand(255), rand(255))
x = rand(cw - 8)
y = rand(cw - 8)
w = rand(cw - x)
h = rand(cw - y)
brush = TQt::Brush.new(c)
brush.setStyle(TQt::Dense6Pattern)
TQt::debug_level = TQt::DebugLevel::High
painter.fillRect(TQt::Rect.new(x, y, w, h), brush)
TQt::debug_level = TQt::DebugLevel::Off
}
end
end
def bug4
TQt::Application.new(ARGV)
w = CPUWaster.new
w.show
w.draw
end
bug4