Hi,
I can't speak for our Widget maintainers, but in the context of renewed
interest in Qt Lite, I'd suggest to put this behind a feature flag, so
that users who don't actually need scriptable widgets don't have to pay
the price in binary size.
As far as direct drawbacks are concerned, it's mostly the increase in
binary size caused by more data in the meta-objects + it takes a bit
longer to find existing invokables because you have to iterate over more
methods. Though the last point could be mostly avoided by improving
parts of the QMetaObject implementation (Lars had some patches for it).
One thing you probably should consider is however whether it really
makes sense to expose all public methods of Q*Widget to the meta-object
system:
- Some are already (indirectly) exposed via Q_PROPERTY; should anyone
decide to expose those Widgets to QML (or some other language binding
working on the meta-object system), this would cause some friction
because there will be name clashes (QWidget::geometry() vs the geometry
property).
- it probably doesn't make sense to mark overriden virtual methods as
invokable, marking the version in the base class should be enough
- Care must be taken when there are methods returning non-const
references (rare but I believe they exist); I believe we reject such
invokables
- Lastly, templated methods (some of the addAction overloads) can't be
exposed to the meta-object; if you want to expose them, you'd need some
alternative functionality.
Given the above constraints, would the envisioned use-case for
scriptable Widgets work when only exposing a manually selected subset of
methods? Or do you think it only really becomes useful when (almost)
everything is exposed? In other words, can you share your use case?
Fabian
On 28.11.24 08:45, Marcus Tillmanns via Development wrote:
Hi,
I would like to script the creation and usage of all of the QWidget classes.
What’s the likelihood of acceptance (of a merge request) if I were to add
Q_INVOKABLE to the constructors and methods of each QWidget derived class and
QWidget itself?
I guess the downside is enlarged meta objects, but I don’t know if that is seen
as an insurmountable obstacle.
Cheers,
Marcus
--
Fabian Kosmale
Manager R&D
The Qt Company GmbH
Erich-Thilo-Str. 10
D-12489 Berlin
fabian.kosm...@qt.io
+49 1638686070
--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development