I wanted to create a new QML type from C++ but I encountered a problem in the process, which I couldn't resolve. I have a class in C++ - "Mytype" - which has been registered with the QML Type System via qmlregistertype function.
So far so good. The class was correctly registered and the application run fine on desktop environments, everything worked fine. However, when I built and deployed the application to an Android device, I received the following error:
What does this error talk about? What could be the reason for this error? How can I fix it? Please, help me. Here follows a simplified code example:
Code:
#include <QApplication>
#include <QQmlApplicationEngine>
#include "mytype.h"
int main(int argc, char *argv[])
{
qmlRegisterType<Mytype>("mytype", 1, 0, "Mytype");
QQmlApplicationEngine engine;
engine.
load(QUrl(QStringLiteral
("qrc:/main.qml")));
return app.exec();
}
Code:
import mytype 1.0;
...
Mytype {
id: my_type;
...
}