title: How to emit signal in context of specific QML Item from C++ code
body: <p>I have two QML items with the same <em>interface</em> (signals emitted and handled) and different <code>objectName</code> property values:</p>
  
  <pre><code>Text {
      id: the_first_item
      objectName: "the_first_item"
  
      signal ping();
  
      onPing: {
          text = "pong! (variant 1)"
      }
  }
  
  Text {
      id: the_second_item
      objectName: "the_second_item"
  
      signal ping();
  
      onPing: {
          text = "pong! (variant 2)"
      }
  }
  </code></pre>
  
  <p><strong>I want to emit the <code>ping</code> signal in context of one of these items.</strong> In QML i would do it this way:</p>
  
  <pre><code>Item {
      onSomething: the_first_item.ping()
  }
  </code></pre>
  
  <p>The problem is that <strong>I want to do it from C++ code</strong>. I have a pointer to instance of the <code>QQuickItem</code> class retrieved using <code>findChild</code> method and value of <code>objectName</code> property.</p>
  
  <p>The only solution for handling signals triggered from the C++ code I have found was to define its own <code>QObject</code> derivative, declare a signal method in its body and then simply invoke it in context of an instance of this class:</p>
  
  <pre><code>class SomeLogic : public QObject
  {
  public signals:
      void ping();
  
  public:
      void doSth() { ping(); }
  };
  </code></pre>
  
  <p>Then, put a pointer to instance of this class in the engine's root context and connect a handler to this signal in QML in a following way:</p>
  
  <pre><code>Text {
      id: the_first_item
      //objectName: "the_first_item"
  
      Connections {
          target: the_instance_of_some_logic_property_name
          onPing: {
              text = "pong!"
          }
      }
  }
  </code></pre>
  
  <p>But it's not good if I understand things correctly, because if <code>the_second_item</code> is defined in the same way, both of them will handle the <code>ping</code> signal emitted by <code>the_instance_of_some_logic_property_name</code> and I would like to trigger only one of them.</p>
  
  <p>Now, while I am writing it, I think that maybe providing an utility function in each of items and then emit the <code>ping</code> signal in its own context, like that:</p>
  
  <pre><code>Text {
      id: the_first_item
      objectName: "the_first_item"
  
      signal ping();
  
      onPing: {
          text = "pong!"
      }
  
      function emitPing() {
          ping()
      }
  }
  </code></pre>
  
  <p>In a simplier case, the <code>emitPing</code> would be enough (I wouldn't have to define the signal nor handler - I will just set the text in the <code>emitPing</code> function) but if I understand things correctly, the difference between <em>function</em> and <em>signal</em> is that the function invocation is synchronous while the signal is asynchronous and for some reasons (transistions between GUI states initiated from QML but handled in C++) I would like it to be asynchronous. I would also want to avoid necessity to write the no-brainer <code>emitPing</code> function everywhere.</p>
  
  <p><strong>Question</strong>: Is there a way to emit the <code>ping</code> signal, from the C++ code, in context of <code>the_first_item</code> only?</p>