[Interest] How to avoid qml engine repeatedly copying and garbage collecting qstringlists?

NIkolai Marchenko enmarantispam at gmail.com
Mon Oct 23 16:37:21 CEST 2023


>  If you cannot port to Qt6 and compile the QML code to C++

Unfortunately qt6 broke too much of Qt Quick 1 that porting will require
non trivial effort.

On Mon, Oct 23, 2023 at 5:35 PM Ulf Hermann <ulf.hermann at qt.io> wrote:

> > So, should I send the value from qml to c++ to do a search there
> > instead? It's the solution I ended up doing but I hoped storing
> > something on JS side was possible to not cross language boundaries on
> > each item initialization.
>
> If you cannot port to Qt6 and compile the QML code to C++, this may be
> one of the rare cases where you might use a var property in QML. If you
> store the value of the property in a var, the list wrapper is stored,
> not only the list value. Whenever you access it from elsewhere, the
> engine will use the same list wrapper again.
>
> In Qt6 you can use a list<string> instead of var for the same effect,
> but with type.
>
> (At least this is how it should work. I don't think we have a test for
> this particular case. So, if it doesn't work, please file a bug)
>
> best regards,
> Ulf
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20231023/b02905c8/attachment.htm>


More information about the Interest mailing list