On Fri, Jun 24, 2022, at 11:34, Ulf Hermann wrote:
> Indeed, in QQmlEngine the global object is frozen. You cannot replace
> its properties. Apparently you can still add to it, though. But see
> https://codereview.qt-project.org/c/qt/qtdeclarative/+/418536/1 for a
> possible solution.

Since you mentioned I can add members to the Qt object, my current workaround 
is as follows:

#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
    QJSValue qtObject = globalObject.property(QStringLiteral("Qt"));
    auto &qtNamespace = Qt::staticMetaObject;
    for (int i = qtNamespace.enumeratorCount(); i >= 0; --i) {
        auto metaEnum = qtNamespace.enumerator(i);
        for (int k = metaEnum.keyCount(); k >= 0; --k)
            qtObject.setProperty(QString::fromLatin1(metaEnum.key(k)), 
metaEnum.value(k));
    }
#endif

This works in QQmlEngine as well, so I think that'll be fine until these are 
added back properly. :-)

Thanks,
Thorbjørn
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to