[Interest] Scripting within Qt6 and QJSEngine
rainergoebel at gmail.com
Mon Nov 14 12:07:36 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).
> On 14 Nov 2022, at 09:31, Ulf Hermann via Interest <interest at qt-project.org> wrote:
>> That is an intesting question because it somehow pin points something that is
>> not clear to me. Perusing the documentation, I saw that QQmlEngine derives from
>> QJSengine. I cannot figure out which is best to employ in my use case:
>> scripting a QtWidgets C++ application. Can I use QML as a scripting language in
>> a currently C++-only program ?
> Sure, you can. QML, the language, is independent from any UI technology. Most people use it with Qt Quick, but no one forces you to use Qt Quick. When using widgets you'll have to do some more "boring" work yourself: There is no pre-made QtWidgets QML module, but you can certainly register the types you're interested in into your own modules using QML_FOREIGN.
> Mind that structured and constructible value types will only be available from Qt 6.5 on. You can use the snapshot builds already for prototyping, though.
> best regards,
> Interest mailing list
> Interest at qt-project.org
More information about the Interest