<?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[Connections when target is of type QList]]></title><description><![CDATA[<p dir="auto">Hi everyone,</p>
<pre><code>Connections
    {
        target: manager.book
        function onPageListChanged()
        {
            pageThumbnailPanel.updateList(manager.book.pageList)
        }
    }
</code></pre>
<p dir="auto">In this code, we make a connection connection between a <em>manager</em> object and a <em>book</em> which is a <em>manager</em> property. The purpose of this connection and function is to update the list of pages based on changes in the pageList property of manager.book</p>
<p dir="auto">manager and book are both set as context properties</p>
<p dir="auto">pageList is defined in <em>Book.h</em> :</p>
<pre><code>Q_PROPERTY(QList&lt;Page*&gt; pageList READ pageList WRITE setPageList NOTIFY pageListChanged)
</code></pre>
<p dir="auto">Now I want to make a connection between each page of the book and the elements contained in a page. elementList is defined in <em>Page.h</em> :</p>
<pre><code>Q_PROPERTY(QList&lt;Element*&gt; elementList READ elementList WRITE setElementList NOTIFY elementListChanged)
</code></pre>
<p dir="auto">I tried to do something like this :</p>
<pre><code>Connections
    {
        target: manager.book.pageList

        function onElementListChanged()
        {
            for(var i=0; i &lt; manager.book.pageList.length; i++)
            {
                var currentPage = manager.book.pageList[i];
                pagePanel.updateElementList(manager.book.pageList[i].elementList)
            }

        }
    }
</code></pre>
<p dir="auto">But didnt work.</p>
<p dir="auto">Any idea how to correct it ? Thanks in advance</p>
]]></description><link>https://forum.qt.io/topic/146113/connections-when-target-is-of-type-qlist</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 05:16:41 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/146113.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Jun 2023 12:32:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Connections when target is of type QList on Sat, 01 Jul 2023 10:26:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yazid10">@<bdi>Yazid10</bdi></a> said in <a href="/post/763182">Connections when target is of type QList</a>:</p>
<blockquote>
<p dir="auto">But didnt work.</p>
<p dir="auto">Any idea how to correct it ? Thanks in advance</p>
</blockquote>
<p dir="auto">Skipping to the most important part, what does <code>didn't work</code> mean? If there's a compiler or runtime error, include that. If your computer experienced a sudden unexpected self-dissassembly, details please. <code>correct</code> may also require some explanation.</p>
<blockquote>
<p dir="auto">pageList is defined in <em>Book.h</em> :</p>
</blockquote>
<p dir="auto">[...]</p>
<blockquote>
<p dir="auto">Now I want to make a connection between each page of the book and the elements contained in a page. elementList is defined in <em>Page.h</em> :</p>
</blockquote>
<p dir="auto">Try to minimize references to different files. C++ has compilation units, but not "files". Inline rather than giving us .cpp and .h files.</p>
<blockquote>
<p dir="auto">I tried to do something like this :</p>
<pre><code>Connections
    {
        target: manager.book.pageList
</code></pre>
</blockquote>
<p dir="auto">From the previous definition of the pageList property, this may be a manifestation of a documentation failure that has been corrected:<br />
<a href="https://doc.qt.io/qt-6/qml-qtqml-connections.html#target-prop" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qml-qtqml-connections.html#target-prop</a></p>
<blockquote>
<p dir="auto">target : QtObject</p>
<p dir="auto">This property holds the object that sends the signal.</p>
</blockquote>
<p dir="auto">In the <a href="https://doc.qt.io/qt-5/qml-qtqml-connections.html#target-prop" target="_blank" rel="noopener noreferrer nofollow ugc">past</a>, target was specified as Object rather than QtObject. The description states that target should be able to emit a signal, ie be a QObject. A QList property is not a QObject, and therefore can not be a valid Connections target.</p>
]]></description><link>https://forum.qt.io/post/763256</link><guid isPermaLink="true">https://forum.qt.io/post/763256</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Sat, 01 Jul 2023 10:26:57 GMT</pubDate></item></channel></rss>