[Interest] Scripting within Qt6 and QJSEngine

Ulf Hermann ulf.hermann at qt.io
Mon Nov 14 12:19:58 CET 2022

> I think that QML/JS is not viable for scripting of QtWidgets since
> public functions are not available when registering Qt classes as
> types (only slots and Q_INVOKABLE functions next to properties).
> Without the public class functions only very basic functionality is
> exposed to the scripting engine. For custom classes one has of course
> control over what will be exposed but one can not change this for
> existing QtWidget classes (except when changing source code).

"Not viable" is a bit harsh. There are limits to this approach, but
people have done it before. See for example
https://www.kdab.com/declarative-widgets/ . If you want to create the
whole widgets UI declaratively in QML, you're probably going to hit some
major road blocks. However, it doesn't sound like that was the plan
here. If you just need some additional functions exposed to C++, you can
create your own proxy types with additional Q_INVOKABLEs.

best regards,

More information about the Interest mailing list