I'm looking for a scripting language which can be integrated into my Qt5 Application. The application has a public api, which can be used to extend the application with plugins. Now I want to add a scripting language to the application which provides access to the whole public api. The scripting language must fulfill the following Requirements:
I evaluated the following Script-Languages:
What scripting-languages and tools do you suggest, that fulfills all my requirements?
Qt Script is based on the ECMAScript scripting language, as defined in standard ECMA-262. Microsoft's JScript, and Netscape's JavaScript are also based on the ECMAScript standard. For an overview of ECMAScript, see the ECMAScript reference.
Qt uses a command line tool that parses these project files in order to generate "makefiles", files that are used by compilers to build an application. This tool is called qmake. But, we shouldn't bother too much about qmake, since Qt Creator will do the job for us. TEMPLATE describes the type to build.
SWIG with Python seems to be a good choice. SWIG is still actively maintained.
Although SWIG doesn't fulfill all of my requirements out of the box, it shouldn't be that a big thing to make all of them work:
Script Code can be executed from within the QT-Application.
This is not supported out of the box. You have to embed a python interpreter into your application. https://docs.python.org/2/extending/embedding.html
The user can access the file-system, network and create graphical elements from the scripting language.
Accessing the filesystem and network should not be a problem with python. To create graphical userinterfaces, there are a lot of libraries available:
https://wiki.python.org/moin/GuiProgramming
- The user can access the public api of my QT Application through bindings.
- There should be a generator available to automatically generate script-language bindings for my public api.
This is done by SWIG. They provide great C++ and c++11 support.
For classes that are part of the Public Api, it should be possible to pass around objects between the QT-Application and the Scripting Engine.
This is possible using the c++ functions provided by swig:
More info in the External runtime chapter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With