<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi guys,<div><br></div><div>I'm trying to expose my database layer to QML via a QQmlListProperty - however I'm running into problems... I've probably set it up wrong - but I can't figure out where. My C++ skills are a bit rusty after years and years of Java work... :)</div><div><br></div><div>This is my setup code:</div><div><br></div><div>
<pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#800080;">QQmlListProperty</span><<span style=" color:#800080;">Note</span>><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">NoteList</span>::notes()<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">QQmlListProperty</span><<span style=" color:#800080;">Note</span>>(<span style=" color:#808000;">this</span>,<span style=" color:#c0c0c0;"> </span>&<span style=" color:#800000;">_notes</span>,<span style=" color:#c0c0c0;"> </span>&append,</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">                                             </span>&size,</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">                                             </span>&at,</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">                                             </span>&clear);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">}<!--EndFragment--></pre><div><br></div></div><div>These are the actual methods I'm trying to pass in to the list property: </div><div><br></div><div>
<pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">void</span><span style=" color:#c0c0c0;"> </span>append(<span style=" color:#800080;">QQmlListProperty</span><<span style=" color:#800080;">Note</span>><span style=" color:#c0c0c0;"> </span>*property,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">Note</span>*<span style=" color:#c0c0c0;"> </span>value)<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#800080;">NoteList</span><span style=" color:#c0c0c0;"> </span>*list<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>(<span style=" color:#800080;">NoteList</span>*)<span style=" color:#c0c0c0;"> </span>property;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>list->addNote(value);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">void</span><span style=" color:#c0c0c0;"> </span>clear(<span style=" color:#800080;">QQmlListProperty</span><<span style=" color:#800080;">Note</span>><span style=" color:#c0c0c0;"> </span>*property)<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#800080;">NoteList</span><span style=" color:#c0c0c0;"> </span>*list<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>(<span style=" color:#800080;">NoteList</span>*)<span style=" color:#c0c0c0;"> </span>property;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span>list->clearNotes();</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>size(<span style=" color:#800080;">QQmlListProperty</span><<span style=" color:#800080;">Note</span>><span style=" color:#c0c0c0;"> </span>*property)<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#800080;">NoteList</span><span style=" color:#c0c0c0;"> </span>*list<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>(<span style=" color:#800080;">NoteList</span>*)<span style=" color:#c0c0c0;"> </span>property;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span>list->countNotes();</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#808000;">static</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">Note</span>*<span style=" color:#c0c0c0;"> </span>at(<span style=" color:#800080;">QQmlListProperty</span><<span style=" color:#800080;">Note</span>><span style=" color:#c0c0c0;"> </span>*property,<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span>index)<span style=" color:#c0c0c0;"> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#800080;">NoteList</span><span style=" color:#c0c0c0;"> </span>*list<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>(<span style=" color:#800080;">NoteList</span>*)<span style=" color:#c0c0c0;"> </span>property;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">return</span><span style=" color:#c0c0c0;"> </span>list->noteAt(index);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><br><!--EndFragment--></pre><div>When I compile - I get this:</div></div><div>/Users/markus/Documents/SailfishOS/build-SilicaNote-MerSDK_SailfishOS_i486_x86-Debug/notelist.o:-1: In function `QQmlListProperty'</div><div>/usr/include/qt5/QtQml/qqmllist.h:72: error: undefined reference to `NoteList::append(QQmlListProperty<Note>*, Note*)</div><div>File not found: /usr/include/qt5/QtQml/qqmllist.h</div><div>/usr/include/qt5/QtQml/qqmllist.h:72: error: undefined reference to `NoteList::at(QQmlListProperty<Note>*, int)'</div><div>File not found: /usr/include/qt5/QtQml/qqmllist.h</div><div>/usr/include/qt5/QtQml/qqmllist.h:72: error: undefined reference to `NoteList::clear(QQmlListProperty<Note>*)'</div><div>File not found: /usr/include/qt5/QtQml/qqmllist.h</div><div>:-1: error: collect2: ld returned 1 exit status</div><div><br></div><div>Does anyone have any idea what I'm doing wrong?</div><div><br></div><div>The broken code is in a separate branch on GitHub - <a href="https://github.com/Ortofta/SilicaNote/tree/borked">https://github.com/Ortofta/SilicaNote/tree/borked</a> - feel free to look around.</div><div>It is a WIP and learning experience - so don't expect greatness.</div><div><br></div><div>Thanks!</div></body></html>