summaryrefslogtreecommitdiffstats
path: root/qtruby/rubylib/examples/testcases/bugs.rb
blob: 215aea19b4eb642babdd4b5640ad9deb82919a25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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, TQ_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