How easy is Lua with Qt, compared to QtScript?

12,257

Solution 1

I've encountered the same dilemma. I much prefer Lua to ECMAScript for these sorts of tasks. However, as easy as it is to write Lua bindings, the level of integration provided by QtScript yields a lot of capability out of the box. This includes bindings to built-in QObject-derived classes as well as your own classes that inherit from QObject and/or QScriptClass.

So, if you only want to script or configure your own classes independent from Qt functionality, then I'd go with Lua. However, if you primarily want to interact with QObject-based types, then QtScript will greatly decrease your initial development time.

The best of both worlds would be the option to parse Lua scripts with an alternate QScriptEngine implementation. I've been meaning to look into how difficult that would be to integrate for some time...

UPDATE: QtLua is still actively maintained and might solve your problem directly.

Solution 2

Javascript is so well integrated right now, if you want to integrate lua you will probably have a much higher upfront effort. Also the current implementation (4.6) uses the webkit javascript engine, which means it is blazingly fast.

I have used Javascript and Qt for a current project and it was pretty easy to transport data either way (Qt to Javascript, and the reverse)

Share:
12,257
DaveO
Author by

DaveO

Updated on July 19, 2022

Comments

  • DaveO
    DaveO almost 2 years

    I'm just starting C++ development using Qt. However, I'm also interested in using Lua to script my app, given various articles stating its development speed (ease) for writing the workflow/ui/glue of an application. However, out of the box Qt doesn't support it, instead it includes QtScript.

    My question is basically should I attempt to use Lua with Qt to develop a commercial app, or stick with QtScript available in the SDK? Primarily a development speed vs. stability question I guess.

  • Valentin H
    Valentin H about 5 years
    despite the answer is old, it is worth to mention, that using QScript even in a commercial means, the code should comply LGPL. So either the complete code should be OS or at least the part using QScript (e.g. implemented as a lib).