Im am trying to make a very basic Qt application that will use C++ for the data model and QML for the GUI. To my surprise it is not easy to find a good tutorial for this, so it's very much "trial and error". This is the code I've got so far:

main.cpp:

Qt Code:
  1. #include <QtDeclarative>
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5. QApplication app(argc, argv);
  6.  
  7. QDeclarativeView view;
  8. view.setSource(QUrl::fromLocalFile("qml/myapp/main.qml"));
  9. view.show();
  10.  
  11. QObject *root = view.rootObject();
  12.  
  13. QObject::connect(root, SIGNAL(quit()), &app, SLOT(quit()));
  14.  
  15. return app.exec();
  16. }
To copy to clipboard, switch view to plain text mode 

main.qml:
Qt Code:
  1. import QtQuick 1.0
  2.  
  3. Rectangle {
  4. width: 360
  5. height: 360
  6. Text {
  7. text: "Hello World"
  8. anchors.centerIn: parent
  9. }
  10. signal quit()
  11. MouseArea {
  12. anchors.fill: parent
  13. onClicked: {
  14. quit();
  15. }
  16. }
  17. }
To copy to clipboard, switch view to plain text mode 

What it does is very simple: it shows a rectangle with the text "Hello World", and when you click in the rectangle the program quits. I know that this is exactly the same as the default app that Qt Creator creates when you choose to make a new "Qt Quick Application", but my app does it another and (I think) generally more useful way as I don't just start a QML program that sort of lives its own life but actually establish a connection between the C++ layer and the QML layer (with the signal/slot connection).

Now to the problem. This runs without errors for the Desktop target. But if I choose the Qt Simulator as target it still runs, but I get this message in the console:

Object::connect: No such signal QDeclarativeRectangle::quit()

When I click the rectangle the app doesn't quit, and the console says:

Signal QDeclarativeEngine::quit() emitted, but no receivers connected to handle it.

Can someone please correct my code?