So yes ... I am back with the solution for those of you who don't don't use QT for a living like Mr. Lukas and are still interested in how things work. As Volker pointed out the QDeclarativeView, as every other GUI class, must live in the main thread. That is why the following code does not work:
@int main(int argc, char ** argv)
{
QCoreApplication* app = qApp;
return qApp->exec();
return app.exec();
}@
Strange looking code I know but I tried it. :) Basically, in layman terms we are trying to run an application within an application using the same memory space. (Or some thing like that). Definitely not the correct way to do things. So what can we do, well there's...
@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("application.qml"));
view.show();
return app.exec();
}@
This works but keep in mind that this creates the QDeclarativeView instance as a variable on the stack.
However if you use the code:
@int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView *qmlView = new QDeclarativeView;
qmlView->setSource(QUrl::fromLocalFile("myQML.qml"));
qmlView->show();
return app.exec();
}@
the QDeclarativeView is not instanced on the stack rather on what I think Lukas was referring to as the "heap". (The heap is the name for a block of RAM that is used to store dynamic variables). One thing to keep in mind is that in the first example the QDeclarativeView instance is automatically destroyed when the function terminates, but in the second example we can use delete on a main window when we have finished with it to save memory.
So to reference my particular situation there was already and event loop which had been started by Maya. So all I had to do was add this to my function:
@int myFunction(){
QDeclarativeView *qmlView = new QDeclarativeView;
qmlView->setSource(QUrl::fromLocalFile("myQML.qml"));
qmlView->show();
}@
And that's pretty much it. :) Hopefully others will find this information more helpful then just telling them to go get an education. :)