4 local i
= QLabel
.__index
5 QLabel
.__index
= function (...) print('QLabel required', ...) return i(...) end
9 local i
= QPushButton
.__index
10 QPushButton
.__index
= function (...) print(...) local ret
= { i(...) } print(unpack(ret
)) return unpack(ret
) end
14 slot
= function(s
) return '1'..tostring(s
) end,
15 signal
= function(s
) return '2'..tostring(s
) end,
19 --app = QApplication.new()
24 --QApplication.new = app
28 --print( pcall( app ) )
31 QApplication.new = app
34 --print( QApplication.new )
35 --print( pcall( QApplication.new ) )
38 app
= QApplication
.new()
42 mainwin
= QWidget
.new()
46 layout
= QVBoxLayout
.new()
48 mainwin
:setLayout(layout
)
49 mainwin
:setWindowTitle
'lqt test window'
53 te
:setToolTip
'I\'m the Code Edit Box: I hold the code while you edit'
57 but = QPushButton.new()
59 but:connect(qt.signal'pressed()', but, qt.slot'close()')
60 but:setText'Close Me!'
62 but:setFont(QFont.new('Times', 18, 75))
67 buttons = buttons or {}
70 but = QPushButton.new()
73 but:connect(qt.signal'pressed()', but, qt.slot'close()')
74 but:setText'Close Me!'
75 but:setWindowTitle('Button '..i)
77 but:setFont(QFont.new('Times', 18, 75))
81 return 'Created button '..i
89 pb
= QPushButton
.new()
95 pb
:setToolTip
'I\'m the Exec button: push me to execute your code'
99 quit
= QPushButton
.new()
100 layout
:addWidget(quit
)
102 quit
:setToolTip
'I\'m the Quit button: push me to close all windows'
105 --pb:connect('2pressed()', SLOT(function() print 'lqt RULES!' end))
106 --pb:connect('2pressed()', SLOT(function() print 'lqt ROCKS!' end))
108 results
= QLabel
.new()
109 results
:setToolTip
'I\'m the result bar: I will show you your results and your errors'
110 layout
:addWidget(results
)
112 pb
:connect('2pressed()', SLOT(function()
113 local f
, err
= loadstring(te
:toPlainText())
117 local res
= { pcall( f
) }
120 for i
, r
in ipairs(res
) do
121 if i
~=1 then string = string .. tostring(r
) .. ', ' end
123 results
:setText(string)
125 results
:setText(res
[2])
129 quit
:connect('2pressed()', app
, '1closeAllWindows()')