File: t7.rb

package info (click to toggle)
qtruby 4%3A4.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,564 kB
  • sloc: ruby: 24,603; cpp: 23,004; makefile: 63; sh: 8
file content (42 lines) | stat: -rwxr-xr-x 1,066 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env ruby
$VERBOSE = true; $:.unshift File.dirname($0)

require 'Qt4'
require 'lcdrange.rb'

class MyWidget < Qt::Widget

    def initialize(parent = nil)
        super(parent)
        quit = Qt::PushButton.new('Quit')
        quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold))
    
        connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()'))

        grid = Qt::GridLayout.new
        previousRange = nil
        for row in 0..3
            for column in 0..3
                lcdRange = LCDRange.new(self)
                grid.addWidget(lcdRange, row, column)
                if previousRange != nil
                    connect( lcdRange, SIGNAL('valueChanged(int)'),
                             previousRange, SLOT('setValue(int)') )
                end
                previousRange = lcdRange
            end
        end

        layout = Qt::VBoxLayout.new
        layout.addWidget(quit)
        layout.addLayout(grid)
        setLayout(layout)
    end

end    

app = Qt::Application.new(ARGV)

widget = MyWidget.new
widget.show
app.exec