<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Actually, that's the best solution so far. Just make sure you follow the structure of the in qml/js of data inside QVariantList. Playing around QVariant and *List is a bit tricky
but once you get the hang of it, it's awesome datatype.<br>
<br>
thanks,Jarko<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF414161"><font color="#000000" face="Tahoma" size="2"><b>From:</b> devel-bounces@lists.sailfishos.org [devel-bounces@lists.sailfishos.org] on behalf of Mikko Leppänen [mleppan23@gmail.com]<br>
<b>Sent:</b> Friday, May 23, 2014 11:20 AM<br>
<b>To:</b> Sailfish OS Developers<br>
<b>Subject:</b> Re: [SailfishDevel] Technical question: populating ListModel from C++<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div class="gmail_default" style="font-family:tahoma,sans-serif">Hi,<br>
<br>
</div>
<div class="gmail_default" style="font-family:tahoma,sans-serif">Or if you don't want to subclass e.g. qabstractitemmodel, you can always return a QVariantList(or QList) from c++ and expose that sequence to QML. Then use that JS array to populate ListModel.<br>
<br>
</div>
<div class="gmail_default" style="font-family:tahoma,sans-serif">/Mikko <br>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2014-05-23 10:53 GMT+03:00 Markus Svensson <span dir="ltr">
<<a href="mailto:markus.svensson@me.com" target="_blank">markus.svensson@me.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="auto">
<div>Hi,</div>
<div><br>
</div>
<div>I have done the same thing in my Sailfish learning project. It was way more complicated than I would have liked it to be (or maybe I did it in the wrong way...).</div>
<div><br>
</div>
<div>Feel free to have a look at how I implemented it: <a href="https://github.com/Ortofta/SilicaNote" target="_blank">
https://github.com/Ortofta/SilicaNote</a></div>
<div><br>
</div>
<div>The code quality is probably not the best - these are my first baby steps in QT and Sailfish. ;)</div>
<div><br>
</div>
<div>Regards,</div>
<div>Markus<br>
<br>
</div>
<div><br>
23 maj 2014 kl. 08:52 skrev Kimmo Lindholm <<a href="mailto:Kimmo.Lindholm@eke.fi" target="_blank">Kimmo.Lindholm@eke.fi</a>>:<br>
<br>
</div>
<div>
<div>
<blockquote type="cite">
<div>
<div>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="EN-GB">Hi,,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="EN-GB">Thank you Janne and Jarko, I will take a look on both of these approaches;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="EN-GB">></span><span style="font-size:10pt; font-family:"Tahoma","sans-serif"; color:black" lang="EN-GB"> use the QSqlQueryModel in your c++ and expose that to QML ; just like in :
</span><span style="font-size:10pt; font-family:"Tahoma","sans-serif"; color:black"><a href="http://qt-project.org/wiki/How_to_use_a_QSqlQueryModel_in_QML" target="_blank"><span lang="EN-GB">http://qt-project.org/wiki/How_to_use_a_QSqlQueryModel_in_QML</span></a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt; font-family:"Tahoma","sans-serif"; color:black"><u></u> <u></u></span></p>
<p><span lang="EN-US">> subclassing QAbstractItemModel. See <a href="http://qt-project.org/doc/qt-5/qtquick-modelviewsdata-cppmodels.html" target="_blank">
http://qt-project.org/doc/qt-5/qtquick-modelviewsdata-cppmodels.html</a> and <a href="http://qt-project.org/doc/qt-5/qabstractitemmodel.html" target="_blank">
http://qt-project.org/doc/qt-5/qabstractitemmodel.html</a> to get started.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="EN-GB">-kimmo<u></u><u></u></span></p>
</div>
</div>
</blockquote>
</div>
</div>
<blockquote type="cite">
<div><span>_______________________________________________</span>
<div><br>
<span><a href="http://SailfishOS.org" target="_blank">SailfishOS.org</a> Devel mailing list</span><br>
<span>To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">
devel-unsubscribe@lists.sailfishos.org</a></span></div>
</div>
</blockquote>
</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>
<br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>