<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to hook up to the onClick event of a QML item from C++ side using the QQuickItem pointer to the QML item]]></title><description><![CDATA[<p dir="auto"><strong>Scenario:</strong><br />
I have a <em>Qt app</em> which runs on <em>Qt 5.9.4</em> commercial edition. Its a <code>QtQuick</code> and <code>QML</code> based application which is running on <em>iOS</em> and <em>Android</em>.</p>
<p dir="auto">I have a <code>QML</code> item on the UI like this:</p>
<pre><code>SomeItem {
    text: qsTr("Some Item")
    objectName: "someitem"
    visible: false
    onClicked: {
        console.log("Some item was clicked")
    }
}
</code></pre>
<p dir="auto">I have a C++ function which can easily control the properties of <code>SomeItem</code>.</p>
<pre><code>void MyCppClass::Func() {

    QQuickItem *someItem = qml_engine-&gt;rootObjects()[0]-&gt;findChild&lt;QQuickItem*&gt;("someitem");
    someItem-&gt;setVisible(true); // this works

    // How to listen to someItem's onClick event here
}
</code></pre>
<p dir="auto"><strong>Question:</strong><br />
I want to listen to the onClick event of <code>someItem</code> in a C++ method or a lambda without changing anything in the QML. Basically hook up to the onClick signal signal of <code>someItem</code> from C++ side itself. How can I do it?</p>
]]></description><link>https://forum.qt.io/topic/95732/how-to-hook-up-to-the-onclick-event-of-a-qml-item-from-c-side-using-the-qquickitem-pointer-to-the-qml-item</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 08:21:39 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/95732.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 19 Oct 2018 16:32:02 GMT</pubDate><ttl>60</ttl></channel></rss>