[Interest] How to avoid qml engine repeatedly copying and garbage collecting qstringlists?
Ulf Hermann
ulf.hermann at qt.io
Mon Oct 23 16:35:45 CEST 2023
> 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
More information about the Interest
mailing list