void AddLogger(const QString& name, QObject* logger, QQmlContext* context)
     {
         logger->setParent(context);
         QQmlEngine::setContextForObject(logger, context);
         context->setContextProperty(name, logger);
     }

This is actually not a JavaScript global, but a context property. Context properties are even worse from the perspective of analysis ahead of time. They don't even apply to all code, but only to the objects that happen to live in the context you've chosen. A side effect of this is that your QML code is not usable outside of such specific contexts. You can't give your QML file to someone else and have them integrate it into a different program because your QML file makes implicit assumptions about its context. So, your QML components are in fact not re-usable.

It's much better to openly declare your assumptions using imports. Then the receiver of the QML file at least has a chance to track down the dependencies.

best regards,
Ulf Hermann
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to