无法加载 QML 插件:无法保护模块,因为它从未注册过
Unable to load QML plugin: cannot protect module as it was never registered
我无法从C++加载 qml 文件:
QQmlComponent component(&engine, QUrl("qrc:/qml/Singletons.qml"));
在此文件的顶部,我们有
import My.Module 1.0
错误是 (component.errorString()
(:
plugin cannot be loaded for module "My.Module": Cannot protect module My.Module 1 as it was never registered
My.Module
是一个仅包含 qml 的插件。它已使用QQmlEngine::importPlugin
成功加载。qml 组件位于 qrc 中并被编译。我不在插件本身中注册任何类型。这适用于Qt 5.14.1,但不适用于Qt 5.15.0
原因是我没有注册任何类型,在这种情况下,事实证明您需要调用qmlRegisterModule
:
void MyModulePlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("My.Module"));
qmlRegisterModule(uri, 1, 0);
}
相关文章:
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 无法将结构注册为增强几何体3D点
- 如何使用AngelScript注册SFML Vector2运算符
- 在遍历处理程序的向量时注册和注销处理程序
- 有没有任务栏API可以立即应用注册表更改
- 使用QJsEngine在Qt中注册自定义类型
- 检查注册表项是否链接到(或副本)另一个注册表项
- 如何使用 TStyleManager::UnRegisterStyle() 取消注册样式
- 我可以在这里替换什么,因为我不能在 C# 中使用隐式变量的 lambda 函数?
- WINAPI 注册应用程序重新启动时不清除打开的套接字
- SFML 碰撞永远不会在我的系统中注册
- 尝试从C++访问 UWP 的电子邮件邮件类会导致"REGDB_E_CLASSNOTREG类未注册"错误
- 用于创建/注册虚拟存储设备的 IOKit 驱动程序
- 程序无法启动,因为缺少 libmpc-3.dll
- 如何添加预防措施以绕过未注册Microsoft.ACE.OLEDB.12.0?
- 数组类型 int[n][n] 不可赋值,因为表达式必须具有常量值
- 在这个函数中是有缺陷的,因为取消引用 null 是无效的,所以我想更改代码
- 无法为 X.radio 创建中等可视化,因为找不到网络节点可视化 - Omnet++
- 在编译时,C++项目抛出错误 C2228,这是预期的,因为控件在运行时未达到该点
- 无法加载 QML 插件:无法保护模块,因为它从未注册过