4 Copyright (c) 2007-2008 Mauro Iazzi
6 Permission is hereby granted, free of charge, to any person
7 obtaining a copy of this software and associated documentation
8 files (the "Software"), to deal in the Software without
9 restriction, including without limitation the rights to use,
10 copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the
12 Software is furnished to do so, subject to the following
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 OTHER DEALINGS IN THE SOFTWARE.
31 local i
= QLabel
.__index
32 QLabel
.__index
= function (...) print('QLabel required', ...) return i(...) end
36 local i
= QPushButton
.__index
37 QPushButton
.__index
= function (...) print(...) local ret
= { i(...) } print(unpack(ret
)) return unpack(ret
) end
41 slot
= function(s
) return '1'..tostring(s
) end,
42 signal
= function(s
) return '2'..tostring(s
) end,
46 --app = QApplication.new()
51 --QApplication.new = app
55 --print( pcall( app ) )
58 QApplication.new = app
61 --print( QApplication.new )
62 --print( pcall( QApplication.new ) )
65 app
= QApplication
.new()
69 mainwin
= QWidget
.new()
73 layout
= QVBoxLayout
.new()
75 mainwin
:setLayout(layout
)
76 mainwin
:setWindowTitle
'lqt test window'
80 te
:setToolTip
'I\'m the Code Edit Box: I hold the code while you edit'
84 but = QPushButton.new()
86 but:connect(qt.signal'pressed()', but, qt.slot'close()')
87 but:setText'Close Me!'
89 but:setFont(QFont.new('Times', 18, 75))
94 buttons = buttons or {}
97 but = QPushButton.new()
100 but:connect(qt.signal'pressed()', but, qt.slot'close()')
101 but:setText'Close Me!'
102 but:setWindowTitle('Button '..i)
104 but:setFont(QFont.new('Times', 18, 75))
108 return 'Created button '..i
116 pb
= QPushButton
.new()
122 pb
:setToolTip
'I\'m the Exec button: push me to execute your code'
126 quit
= QPushButton
.new()
127 layout
:addWidget(quit
)
129 quit
:setToolTip
'I\'m the Quit button: push me to close all windows'
132 --pb:connect('2pressed()', SLOT(function() print 'lqt RULES!' end))
133 --pb:connect('2pressed()', SLOT(function() print 'lqt ROCKS!' end))
135 results
= QLabel
.new()
136 results
:setToolTip
'I\'m the result bar: I will show you your results and your errors'
137 layout
:addWidget(results
)
139 pb
:connect('2pressed()', SLOT(function()
140 local f
, err
= loadstring(te
:toPlainText())
144 local res
= { pcall( f
) }
147 for i
, r
in ipairs(res
) do
148 if i
~=1 then string = string .. tostring(r
) .. ', ' end
150 results
:setText(string)
152 results
:setText(res
[2])
156 quit
:connect('2pressed()', app
, '1closeAllWindows()')