Qt Script template is a CMake project to create your classes 'scriptable'. If you have library with some QObject or non-QObject based classes, it's the fatest way to create QtScript bindings.
First of all you need QtScriptGenerator (hereinafter QSG) from my repository:
git clone git://gitorious.org/~asvil/qt-labs/asvils-qtscriptgenerator.git qtscriptgenerator
cd qtscriptgenerator
git clone git://gitorious.org/~asvil/qt-labs/asvils-qtscriptgenerator.git qtscriptgenerator
cd qtscriptgenerator
To copy to clipboard, switch view to plain text mode
Than make QSG:
cd generator
qmake
make
cd generator
qmake
make
To copy to clipboard, switch view to plain text mode
Optionally
Create Qt Modules bindings.
Execute QSG without parameters, than make plugin projects:
./generator
cd ../qtbindings
qmake && make
./generator
cd ../qtbindings
qmake && make
To copy to clipboard, switch view to plain text mode
If you don't have all Qt modules, make subdirs particularly:
cd ../qtbindings/qtscript_core
qmake && make
#etc
cd ../qtbindings/qtscript_core
qmake && make
#etc
To copy to clipboard, switch view to plain text mode
After this manipulation, download qtscriptemplate:
git clone git://gitorious.org/qtscripttemplate/qtscripttemplate.git qtscripttemplate
cd qtscripttemplate
mkdir include
mkdir lib
git clone git://gitorious.org/qtscripttemplate/qtscripttemplate.git qtscripttemplate
cd qtscripttemplate
mkdir include
mkdir lib
To copy to clipboard, switch view to plain text mode
Place your include files into 'include', your libraries into 'lib'.
Edit three files in 'buildplugin' subdirectory:
CMakeLists.txt
plugin_build.txt.in
plugin_typesystem.xml.in
In CMakeLists.txt replace uncomment two strings and print your plugin project names:
# Plugin file name
set (PROJECT YOUR_SCRIPT_PLUGIN_NAME)
# Extension name for method QScriptEngine::importExtension().
set (QS_PACKAGE_NAME YOUR_PACKAGE_NAME)
# Plugin file name
set (PROJECT YOUR_SCRIPT_PLUGIN_NAME)
# Extension name for method QScriptEngine::importExtension().
set (QS_PACKAGE_NAME YOUR_PACKAGE_NAME)
To copy to clipboard, switch view to plain text mode
Add Qt Modules your library using in CMake project, for example:
set(QT_USE_QTNETWORK TRUE)
In plugin_build.txt.in uncomment Qt modules your library using.
Edit plugin_typesystem.xml.in (read more here):
For namecpaces add tag: <namespace-type name="YourNamespace"/>
For enums:
<enum-type name="Namespace::SomeEnum"/>
or
<enum-type name="SomeClass::SomeEnum"/>
For QObject based classes with Q_OBJECT macro:
<object-type name="QObjectSubclass"/>
For non-QObject based classes, haves copy constructor and assignment operator
<value-type name="NonQObjectClass"/>
Than make buildplugin/CMakeLists.txt with this commands, cmake called QSG to generate bindings for your classes:
cmake buildplugin -DCMAKE_BUILD_TYPE=Release
make
cmake buildplugin -DCMAKE_BUILD_TYPE=Release
make
To copy to clipboard, switch view to plain text mode
'plugins/script' is the output directory for plugin.
For some libraries created appropriate branch: log4qt, ncreport252, qserialdevice. By switching to these branches need only to copy the headers and the library itself.
Example:
git branch --track origin/qserialdevice
mkdir lib
mkdir include
.....................
# Copy qserialdevice library and headers
.....................
cmake biuldplugin -DCMAKE_BUILD_TYPE=Release
make
git branch --track origin/ncreport252
mkdir lib
mkdir include
.....................
# Copy ncreport >= 2.5.2 library and headers
.....................
cmake biuldplugin -DCMAKE_BUILD_TYPE=Release
make
git branch --track origin/qserialdevice
mkdir lib
mkdir include
.....................
# Copy qserialdevice library and headers
.....................
cmake biuldplugin -DCMAKE_BUILD_TYPE=Release
make
git branch --track origin/ncreport252
mkdir lib
mkdir include
.....................
# Copy ncreport >= 2.5.2 library and headers
.....................
cmake biuldplugin -DCMAKE_BUILD_TYPE=Release
make
To copy to clipboard, switch view to plain text mode
Bookmarks