Fix a (harmless) copy-paste typo
[lqt/mk.git] / test / t6.lua
blob56543b916a746c89ed6088f147bb64f1e5878620
1 #!/usr/bin/lua
3 require'qtcore'
4 require'qtgui'
6 local LCD_Range = function(...)
7 local this = QWidget.new(...)
9 local lcd = QLCDNumber.new()
10 lcd:setSegmentStyle'Filled'
12 local slider = QSlider.new'Horizontal'
13 slider:setRange(0, 99)
14 slider:setValue(0)
16 QObject.connect(slider, '2valueChanged(int)', lcd, '1display(int)')
18 local layout = QVBoxLayout.new()
19 layout:addWidget(lcd)
20 layout:addWidget(slider)
21 this:setLayout(layout)
22 return this
23 end
25 local new_MyWidget = function(...)
26 local this = QWidget.new(...)
28 local quit = QPushButton.new('Quit')
29 quit:setFont(QFont('Times', 18, 75))
30 QObject.connect(quit, '2clicked()', QCoreApplication.instance(), '1quit()')
32 local grid = QGridLayout.new()
33 for row = 1, 3 do
34 for column = 1, 3 do
35 local lcdrange = LCD_Range()
36 grid:addWidget(lcdrange, row, column)
37 end
38 end
40 local layout = QVBoxLayout.new()
41 layout:addWidget(quit)
42 layout:addLayout(grid)
43 this:setLayout(layout)
44 return this
45 end
47 app = QApplication.new(1 + select('#', ...), {arg[0], ...})
48 app.__gc = app.delete -- take ownership of object
50 widget = new_MyWidget()
51 widget:show()
53 app.exec()