Hello friends,
I have expose one c++ classes to qml in a main.cpp file like this:
int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
qmlRegisterType<MyTestClass>("Test", 1, 0, "Test");
QQuickView view;
view.resize(800, 480);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.
setSource(QUrl("qrc:///main.qml"));
view.show();
return app.exec();
}
int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
qmlRegisterType<MyTestClass>("Test", 1, 0, "Test");
QQuickView view;
view.resize(800, 480);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:///main.qml"));
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
But my root object in qml is a ApplicationWindow object. So I get a
QQuickView only supports loading of root objects that derive from QQuickItem.
So when I avoid the main.cpp I have to run the qml file with qmlscene. But I want to have an exe file. How can I use an main.cpp in combinatiion with a ApplicationWindow root object in a qml file?
Yours,
Bookmarks