[Interest] Scripting within Qt6 and QJSEngine

Filippo Rusconi listes.rusconi at laposte.net
Thu Nov 10 09:38:36 CET 2022


Greetings, 

some months ago I had posted a message about using QJSEngine in place of
QtScript. Indeed, I did not find any tutorial about doing that transition in the
C++ -- not QML -- context.

I have read tons of websites and pages and it is still unclear to me how to
simply expose the following struct to QJSEngine:

struct DataPoint
{
double x;
double y;
};

I understand well that exposing QObject-derived classes is straightforward:
Q_OBJECT, slots/Q_INVOKABLE magic. But it is still not clear to me how to expose
classes not deriving from QObject.

Does anybody has some code to share that would enlighten me in this pretty dark
path? Or lessons learnt while experiencing the same hardship?

My software is about displaying traces with millions of DataPoint instances, I
guess it is not viable to morph that simple struct into a QObject-derived class.
Is there any knowledge about the overhead that such a morph would impose
size-wise?

Thanks for any help,

Sincerely,
Filipp

-- 

⢀⣴⠾⠻⢶⣦⠀  Filippo Rusconi, PhD
⣾⠁⢠⠒⠀⣿⡁   Scientist at CNRS
⢿⡄⠘⠷⠚⠋⠀   Debian Developer
⠈⠳⣄⠀⠀⠀⠀  http://msxpertsuite.org
           http://www.debian.org




More information about the Interest mailing list