I don't know what you did exactly to get this error but the line I gave you is the only change I made to the whole program (apart including headers for your classes, of course).
#include "object1.h"
#include "object2.h"
int main(int argc, char *argv[])
{
QDeclarativeView view;
qmlRegisterType<Object2>("com.test.object", 1, 0, "Object2");
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
Object1 *object1 = new Object1();
view.rootContext()->setContextProperty("myObject1",object1);
view.
setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
}
#include "object1.h"
#include "object2.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
qmlRegisterType<Object2>("com.test.object", 1, 0, "Object2");
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
Object1 *object1 = new Object1();
view.rootContext()->setContextProperty("myObject1",object1);
view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks