lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Again, about binding other C++ API:s.

I have browsed the code, trying to bind some sample API:s, one issue is the include structure of Qt is rather odd...


When generating cpp-files, the lua files adds 

#include "libname"

and

#include <libname>

where libname is the:

cpptoxml libname <rest of the arguments>

I know, that Qt is sort of not so strict when it comes to include directories.
A common rule is that classes in namespace Y is included as:

<Y/yclassA> (or <Y/yclassA.h/.hpp>

Comments?

On Wed, Aug 27, 2008 at 7:05 PM, Peter Kümmel <syntheticpp@gmx.net> wrote:
Here an update on the current status of lqt, a Qt binding,
http://repo.or.cz/w/lqt.git

Now we bind on Linux and Windows these Qt libraries:

QtCore
QtGui
QtNetwork
QtOpenGL
QtScript -- executing _javascript_ from Lua  ;)
QtSvg
QtWebKit
QtXml

The build process is now much simpler:
cmake ..\lqt
make


Basic functionality is tested but much more tests are needed.


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.lua.org:

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.lua.org')))
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!

Best regards,
Peter



--
__________________________________________
Anders Backman, CTO  Algoryx Simulation AB
Uminova Science Park, Box 7973,  SE-907 19
Umeå,  Sweden
anders@algoryx.se http://www.algoryx.se
Cell: +46-70-392 64 67