<div dir="ltr"><div>AFAIK you can not call any variables inside components from outside of components<br></div>use <br><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)">QmlListModel</span>{<span style="color:rgb(128,0,0)">id</span>:<span style="font-style:italic;color:rgb(0,0,0)">qmlListModel</span>}<br></pre><pre style="margin-top:0px;margin-bottom:0px">indstead of <br><span style="color:rgb(128,0,128)">Component</span>{<span style="color:rgb(128,0,128)">QmlListModel</span>{<span style="color:rgb(128,0,0)">id</span>:<span style="font-style:italic;color:rgb(0,0,0)">qmlListModel</span>}}<br></pre></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 12, 2015 at 9:50 AM, Jollailija Developer <span dir="ltr"><<a href="mailto:jollailija@gmail.com" target="_blank">jollailija@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Okay, I think I found the cause. The function needs to be somewhere where it can see both of the list models. The question is "where is that?"<div>I wrote this into the main QML:</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)"> Component</span>{<span style="color:rgb(128,0,128)">QmlListModel</span>{<span style="color:rgb(128,0,0)">id</span>:<span style="font-style:italic;color:rgb(0,0,0)">qmlListModel</span>}}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">Component</span>{<span style="color:rgb(128,0,128)">StationsModel</span>{<span style="color:rgb(128,0,0)">id</span>:<span style="font-style:italic;color:rgb(0,0,0)">stationsModel</span>}}</pre><span class="">
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">function</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">fillList</span>()<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">i</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>0</pre>
</span><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">r</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>0;<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">r</span><span style="color:rgb(192,192,192)"> </span><<span style="color:rgb(192,192,192)"> </span>10;<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">r</span>++)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">qmlListModel</span>.append({<span style="color:rgb(0,128,0)">"title"</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">stationsModel</span>.get(<span style="font-style:italic;color:rgb(41,133,199)">i</span>).title}) // <- line 92</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">i</span><span style="color:rgb(192,192,192)"> </span>++</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,85,175)">console</span>.log(<span style="font-style:italic;color:rgb(41,133,199)">i</span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)"> Timer</span><span style="color:rgb(192,192,192)"> </span>{</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">interval</span>:<span style="color:rgb(192,192,192)"> </span>5000</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">repeat</span>:<span style="color:rgb(192,192,192)"> </span>false</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">onTriggered</span>:<span style="color:rgb(192,192,192)"> </span>{<span style="font-style:italic;color:rgb(0,0,0)">fillList</span>();<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,85,175)">console</span>.log(<span style="color:rgb(0,128,0)">"fill"</span>)}</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">running</span>:<span style="color:rgb(192,192,192)"> </span>true</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;white-space:normal">Quess what the console says?</span><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:Courier;font-size:10pt;color:rgb(170,0,0)">[W] unknown:92 - </span><a><span style="font-family:Courier;font-size:10pt;color:rgb(0,87,174)">file:///usr/share/harbour-nettiradio/qml/harbour-nettiradio.qml:92</span></a><span style="font-family:Courier;font-size:10pt;color:rgb(170,0,0)">: ReferenceError: qmlListModel is not defined</span><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;white-space:normal">Not defined? It's right there!</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;white-space:normal">I have no idea what I'm doing.</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;white-space:normal">(want to take a look? source at <a href="https://github.com/jollailija/nettiradio" target="_blank">https://github.com/jollailija/nettiradio</a> )</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;white-space:normal"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;white-space:normal">Cheers,</span></pre><pre style="margin-top:0px;margin-bottom:0px"><font face="arial, sans-serif"><span style="white-space:normal">Reference error: jollailija is not defined</span></font></pre></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-12-12 8:02 GMT+02:00 Jollailija Developer <span dir="ltr"><<a href="mailto:jollailija@gmail.com" target="_blank">jollailija@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I switched onCompleted to this:<div><span style="color:rgb(128,0,0)">Component.onCompleted</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">qmlListModel</span>.append({<span style="color:rgb(0,128,0)">"title"</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">stationsModel</span>.get(3).title})</div><div>There should be over 70 items on this list. I think I will need to try to do the conversion at some other place, maybe it can't see it.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-11 21:50 GMT+02:00 Alexander Ladygin <span dir="ltr"><<a href="mailto:fake.ae@gmail.com" target="_blank">fake.ae@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">seems like index out of bounds<br><pre style="margin-top:0px;margin-bottom:0px"><span style="font-style:italic;color:rgb(0,0,0)">stationsModel items count is smaller than </span>lib.stationCount</pre><br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Fri, Dec 11, 2015 at 10:28 PM, Jollailija Developer <span dir="ltr"><<a href="mailto:jollailija@gmail.com" target="_blank">jollailija@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi,<div><br></div><div>I am using Alpha Menu (People app style sorting) in my app. However it only supports QML ListModel as it's dataSource. I tried doing this:</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)"> </span><span style="font-family:arial,sans-serif;color:rgb(128,0,128)">StationsModel</span><span style="font-family:arial,sans-serif;color:rgb(192,192,192)"> </span><span style="font-family:arial,sans-serif">{</span><span style="font-family:arial,sans-serif;color:rgb(128,0,0)">id</span><span style="font-family:arial,sans-serif">:</span><span style="font-family:arial,sans-serif;font-style:italic;color:rgb(0,0,0)">stationsModel</span><span style="font-family:arial,sans-serif">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">ListModel</span><span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">id</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">qmlListModel</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,0)">Component.onCompleted</span>:<span style="color:rgb(192,192,192)"> </span>{<span style="font-style:italic;color:rgb(0,85,175)">console</span>.log(lib.stationCount);<span style="font-style:italic;color:rgb(0,0,0)">fillList</span>()}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">function</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">fillList</span>()<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">i</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>0</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">var</span><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">r</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>0;<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">r</span><span style="color:rgb(192,192,192)"> </span><<span style="color:rgb(192,192,192)"> </span>lib.stationCount;<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">r</span>++)<span style="color:rgb(192,192,192)"> </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">qmlListModel</span>.append({<span style="color:rgb(0,128,0)">"title"</span>:<span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,0,0)">stationsModel</span>.get(<span style="font-style:italic;color:rgb(41,133,199)">i</span>).title}) //< line 52</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(41,133,199)">i</span><span style="color:rgb(192,192,192)"> </span>++</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="font-style:italic;color:rgb(0,85,175)">console</span>.log(<span style="font-style:italic;color:rgb(41,133,199)">i</span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;white-space:normal"> Well, it isn't working. What's wrong with it? Here's the output:</span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:Courier;font-size:10pt;color:rgb(170,0,0)">[W] unknown:52 - </span><a><span style="font-family:Courier;font-size:10pt;color:rgb(0,87,174)">file:///usr/share/harbour-nettiradio/qml/Pages/StationGridView.qml:52</span></a><span style="font-family:Courier;font-size:10pt;color:rgb(170,0,0)">: TypeError: Cannot read property 'title' of undefined</span><span style="font-family:arial,sans-serif;white-space:normal"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:Courier;font-size:10pt;color:rgb(170,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="font-family:arial,sans-serif;white-space:normal"> "Good night to you, dear devs!" wishes<span><font color="#888888"><br>jollailija</font></span></span></pre></div></div>
<br></div></div>_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">devel-unsubscribe@lists.sailfishos.org</a><br></blockquote></div><br></div>
<br>_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">devel-unsubscribe@lists.sailfishos.org</a><br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a><br></blockquote></div><br></div>