一些luaqt的例子
--QT 库
QtCore
QtGui
QtNetwork
QtOpenGL
QtScript --在lua中执行JS
QtSvg
QtWebKit
QtXml
Some examples:
1. Hello World:
require'qtgui'
app = QApplication.new(0, {})
app.__gc = app.delete -- take ownership of object
hello = QPushButton.new(QString.new("Hello World!"))
hello:show()
app.exec()
2. Show www.zaccn.com:
require'qtcore'
require'qtgui'
require'qtwebkit'
app = QApplication.new(0,{})
app.__gc = app.delete -- take ownership of object
webView = QWebView.new()
webView:setUrl(QUrl.new(QString.new('http://www.zaccn.com')))
webView:show()
app.exec()
3. Unicode
require'qtcore'
umlaut = QString.new('Ö')
utf8 = umlaut:toUtf8()
print(string.byte(utf8, 1, #utf8))
4. Evaluate JavaScript
require'qtcore'
require'qtscript'
engine = QScriptEngine.new()
result = engine:evaluate(QString.new('p=function(){print(/"Hello World/");}; p();'))
More examples or tests are welcome!