lqml/cpp-lib
2024-05-23 10:28:06 +02:00
..
cpp revisions 2024-05-23 10:28:06 +02:00
readme.md add convenience macro WITH-ROOT-ITEM (for e.g. QML Repeater items with identical object names) 2022-10-31 20:28:17 +01:00
run.lisp add header for calling ECL from Qt plugins; add cpp-lib example call; revisions 2022-02-21 13:30:22 +01:00

Info

Please see run.lisp, which should be self explaining.

If you want to call Lisp from your Qt plugin, just include ecl_fun_plugin.h, which is independent from LQML, so you could even use it in Qt projects not linking the LQML library.

Function ecl_fun() is convenient because you don't need to care about type conversions, as long as you only use bool, long, double, QString, QByteArray or (nested) QVariant lists of mentioned types.

For the complete list of marshalled types please see toQVariant() and from_qvariant() in marshal.cpp.

Build

$ cd cpp

$ qmake
$ make

$ cd ..

Run

$ lqml ~/slime/lqml-start-swank.lisp
$ emacs run.lisp

After M-x slime-connect and loading run.lisp, you can see that, despite the argument and return type simply being defined as QVariant, you may also pass lists, because a QVariant can also be of type QVariantList, so this is a perfect fit for (nested) Lisp lists.

So, we pass a nested Lisp list, and it gets converted and shown on Qt side with the respective types. Then the QVariantList is returned to Lisp, where it is automatically converted back to a nested Lisp list.