#include #include #include namespace QmlCacheGeneratedCode { namespace _0x5f__main_qml { extern const unsigned char qmlData[]; const QQmlPrivate::CachedQmlUnit unit = { reinterpret_cast(&qmlData), nullptr, nullptr }; } namespace _0x5f__MyCustomQml_qml { extern const unsigned char qmlData[]; const QQmlPrivate::CachedQmlUnit unit = { reinterpret_cast(&qmlData), nullptr, nullptr }; } } namespace { struct Registry { Registry(); ~Registry(); QHash resourcePathToCachedUnit; static const QQmlPrivate::CachedQmlUnit *lookupCachedUnit(const QUrl &url); }; Q_GLOBAL_STATIC(Registry, unitRegistry) Registry::Registry() { resourcePathToCachedUnit.insert(QStringLiteral("/main.qml"), &QmlCacheGeneratedCode::_0x5f__main_qml::unit); resourcePathToCachedUnit.insert(QStringLiteral("/MyCustomQml.qml"), &QmlCacheGeneratedCode::_0x5f__MyCustomQml_qml::unit); QQmlPrivate::RegisterQmlUnitCacheHook registration; registration.version = 0; registration.lookupCachedQmlUnit = &lookupCachedUnit; QQmlPrivate::qmlregister(QQmlPrivate::QmlUnitCacheHookRegistration, ®istration); } Registry::~Registry() { QQmlPrivate::qmlunregister(QQmlPrivate::QmlUnitCacheHookRegistration, quintptr(&lookupCachedUnit)); } const QQmlPrivate::CachedQmlUnit *Registry::lookupCachedUnit(const QUrl &url) { if (url.scheme() != QLatin1String("qrc")) return nullptr; QString resourcePath = QDir::cleanPath(url.path()); if (resourcePath.isEmpty()) return nullptr; if (!resourcePath.startsWith(QLatin1Char('/'))) resourcePath.prepend(QLatin1Char('/')); return unitRegistry()->resourcePathToCachedUnit.value(resourcePath, nullptr); } } int QT_MANGLE_NAMESPACE(qInitResources_)() { ::unitRegistry(); return 1; } Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_)) int QT_MANGLE_NAMESPACE(qCleanupResources_)() { return 1; }