Haven't yet needed a signal slot mechanism between QML and Qt but here's how you can call C++ code from QML:

First you need your class:

Qt Code:
  1. #include <QObject>
  2.  
  3. class MyClass : public QObject
  4. {
  5. Q_OBJECT
  6. public:
  7. explicit MyClass(QObject *parent = 0);
  8.  
  9. Q_INVOKABLE void doThisAndThat(QString myString);
  10. Q_INVOKABLE QString getThisAndThat();
  11.  
  12. signals:
  13.  
  14. public slots:
  15.  
  16. private:
  17.  
  18. QString localThisAndThat;
  19. };
To copy to clipboard, switch view to plain text mode 

And you can create the implementation as you wish, no need to use the Q_INVOKABLE on the implementation side, though.

The you need to introduce this class to QML like this:

Qt Code:
  1. QDeclarativeView::rootContext()->setContextProperty("qmlReferenceName", myClass);
To copy to clipboard, switch view to plain text mode 

So you just give a string of your choice to qmlReferenceName, and pass your class on myClass. After this, you have this class as a global scope variable within your QML code:

Qt Code:
  1. Rectangle {
  2. MouseArea {
  3. anchors.fill: parent
  4. onClicked: { qmlReferenceName.doThisAndThat("It works!") }
  5. }
  6.  
  7. Text {
  8. text: qmlReferenceName.getThisAndThat()
  9.  
  10. }
  11. }
To copy to clipboard, switch view to plain text mode