title: How to catch C++ signal in QML signal handler after type registration?
body: <p>I am developing a basic qml-cpp application to understand how one interacts with another. I have a MessageSetter C++ class and one main.qml. Since I wish to understand two-way communication, I exposed MessageSetter properties to qml using setContextProperty and also registered MessageSetter class with qml (instantiable registration). Exposed properties work fine. Now when a qml button is clicked, then the signal (qmlBtnClicked) is successfully caught in a MessageSetter slot(onQmlButtonClicked). This slot further emits another MessageSetter signal (colorChanged). This new (C++) signal should be caught in qml registered MessageSetter's signal handler (onColorChanged) but it does not arrive here in any case. Below is main.cpp code:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
     QGuiApplication app(argc, argv);
     QQmlApplicationEngine engine;
     qmlRegisterType&lt;MessageSetter&gt;("com.SkillLotto.MessageSetter", 1, 0, "SetMessage");
  
     MessageSetter data;
     engine.rootContext()-&gt;setContextProperty("msgSetter", &amp;data);
     QQmlComponent component(&amp;engine, QUrl::fromLocalFile("main.qml"));
  
     QObject *object = component.create()-&gt;findChild&lt;QObject*&gt;("setTextBtn");
     QObject::connect(object, SIGNAL(qmlBtnClicked()), &amp;data, SLOT(onQmlButtonClicked()));
  
     return app.exec();
  }
  </code></pre>
  
  <p>This is MessageSetter slot that emits another signal:</p>
  
  <pre><code>void MessageSetter::onQmlButtonClicked()
  {
     emit colorChanged("red");
  }
  </code></pre>
  
  <p>This is qml code, this signal handler never gets called:</p>
  
  <pre><code>SetMessage{
      onColorChanged: {
          rect.color = color    //rect is some rectangle in this file.
      }
  }
  </code></pre>
  
  <p>As I stated, qml signal is successfully caught in C++ slot but I am unable to catch this C++ signal in qml signal handler. Any help please.</p>
  
  <p>This question, as I see, is focussed on qmlRegisterType() and should not be duplicate of <a href="https://stackoverflow.com/questions/8834147/c-signal-to-qml-slot-in-qt">this question</a>? I also want to know whether qmlRegisterType() and setContextProperty() cant be used simultaneously or not ?</p>