<?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[No highlighting (go to definition) for injected c++ context property into qml]]></title><description><![CDATA[<p dir="auto">Metadata</p>
<ul>
<li>I use qt 6.7.2</li>
<li>QQmlContext to inject context property</li>
<li>Program works (meaning m_systemHandler's state is changing fine)</li>
</ul>
<p dir="auto">Main.cpp</p>
<pre><code class="language-cpp">#include &lt;QGuiApplication&gt;
#include &lt;QQmlApplicationEngine&gt;
#include &lt;QQuickView&gt;
#include &lt;QQmlContext&gt;

#include &lt;controllers/system.h&gt;

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;

    System m_systemHandler;
    QQmlContext * rootcontext = engine.rootContext();
    rootcontext-&gt;setContextProperty( "systemHandler", &amp;m_systemHandler );

    const QUrl url(QStringLiteral("qrc:/TeslaInfotainment/main.qml"));
    QObject::connect(
        &amp;engine,
        &amp;QQmlApplicationEngine::objectCreated,
        &amp;app,
        [url](QObject *obj, const QUrl &amp;objUrl) {
            if (!obj &amp;&amp; url == objUrl)
                QCoreApplication::exit(-1);
        },
        Qt::QueuedConnection);
    engine.load(url);

    return app.exec();
}
</code></pre>
<p dir="auto">RightScreen.qml where injected class is used:</p>
<pre><code>import QtQuick 2.15
import QtLocation
import QtPositioning

Rectangle {
    id: rightScreen

    anchors {
        top: parent.top
        right: parent.right
        bottom: bottomBar.top
    }
    color: "orange"
    width: parent.width * 2/3

    Image {
        id: lockIcon
        anchors {
            top: parent.top
            left: parent.left
            margins: 20
        }
        width: parent.width / 30
        fillMode: Image.PreserveAspectFit
        source: ( systemHandler.carLocked ? "./secured-lock.png" : "./unlock.png" )

        MouseArea {
            anchors.fill: parent
            onClicked: systemHandler.setCarLocked( !systemHandler.carLocked )
        }
    }
}
</code></pre>
<p dir="auto">I assume this problem should either because of my ide configuration (it is default, just after installation) or this approach to expose a class is no longer a good way. I am following a guide on youtube which was recorded 1 year ago, so idk. If someone will provide resources to read that might help solving this, it would be really great!</p>
]]></description><link>https://forum.qt.io/topic/157488/no-highlighting-go-to-definition-for-injected-c-context-property-into-qml</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 23:38:26 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/157488.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 28 Jun 2024 08:40:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to No highlighting (go to definition) for injected c++ context property into qml on Sat, 29 Jun 2024 11:00:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ekkescorner">@<bdi>ekkescorner</bdi></a> thank you so much!</p>
]]></description><link>https://forum.qt.io/post/803787</link><guid isPermaLink="true">https://forum.qt.io/post/803787</guid><dc:creator><![CDATA[gonpaul]]></dc:creator><pubDate>Sat, 29 Jun 2024 11:00:08 GMT</pubDate></item><item><title><![CDATA[Reply to No highlighting (go to definition) for injected c++ context property into qml on Fri, 28 Jun 2024 17:30:23 GMT]]></title><description><![CDATA[<p dir="auto">instead of context properties you should use QML_SINGLETON.<br />
see <a href="https://ekkesapps.wordpress.com/qt-6-in-action/qmake-cmake/qml_singleton/" target="_blank" rel="noopener noreferrer nofollow ugc">https://ekkesapps.wordpress.com/qt-6-in-action/qmake-cmake/qml_singleton/</a></p>
]]></description><link>https://forum.qt.io/post/803750</link><guid isPermaLink="true">https://forum.qt.io/post/803750</guid><dc:creator><![CDATA[ekkescorner]]></dc:creator><pubDate>Fri, 28 Jun 2024 17:30:23 GMT</pubDate></item></channel></rss>