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

NIkolai Marchenko enmarantispam at gmail.com
Mon Oct 23 22:10:00 CEST 2023


Actually, funnily enough, Qt.fontfamilies is an order of magnitude faster
than custom property wrapping the result of ::families. Dunno why.  5s vs
500 ms for the sue case
Still, checking on .lncludes(name) in javascript is seemingly also an order
of magnitude slower than sending family name to c++ and prematurely exiting
from there. 500 ms vs <50ms

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

> > doesn't QtQuickGuiProvider do the exact same thing with
> QfontDatabase::families?
>
> Yes, it does. It returns a QStringList. What I mean is that you don't
> need a custom C++ base class for your singleton if all you want to do is
> expose the font families in pre-wrapped form. The following is enough
> for that:
>
> pragma Singleton
> import QtQml
>
> QtObject {
>      // Qt5:
>      property var wrappedFontFamilies5: Qt.fontFamilies()
>
>      // Qt6:
>      property list<string> wrappedFontFamilies6: Qt.fontFamilies()
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20231023/29727ecd/attachment.htm>


More information about the Interest mailing list