2
我想从C++创建一个新的QML类型,但是我遇到了一个我无法解决的问题。我有一个C++类 - "Mytype"
- 已通过qmlregistertype
函数向QML类型系统注册。QML导入错误
到目前为止这么好。该类已正确注册并且该应用程序在桌面环境中运行良好,一切正常。但是,当我将应用程序构建并部署到Android设备时,我收到以下错误:
Warning: QML import could not be resolved in any of the import paths: Mytype
这个错误说的是什么?可能是这个错误的原因是什么?我该如何解决它?请帮帮我。这里有个简单的代码示例:
c++:
#include <QApplication>
#include <QQmlApplicationEngine>
#include "mytype.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
qmlRegisterType<Mytype>("mytype", 1, 0, "Mytype");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
qml:
import mytype 1.0;
...
Mytype {
id: my_type;
...
}
请帮帮我! –