> On 28. Nov 2024, at 09:08, Fabian Kosmale via Development > <development@qt-project.org> wrote: > > 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?
As we talked in person (just to keep the info here as well). My use case is binding widgets to Lua in Qt Creator. I will investigate again first how much manual work it would be to expose the important stuff. If that’s too much, I’ll investigate your suggestion of adding a flag to QObjects along the lines of “Q_MAKE_PUBLIC_FUNCTIONS_INVOKABLE” or something like that. Thanks! - Marcus -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development