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.

thanks,Jarko
________________________________
From: devel-boun...@lists.sailfishos.org [devel-boun...@lists.sailfishos.org] 
on behalf of Mikko Leppänen [mleppa...@gmail.com]
Sent: Friday, May 23, 2014 11:20 AM
To: Sailfish OS Developers
Subject: Re: [SailfishDevel] Technical question: populating ListModel from C++

Hi,

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.

/Mikko


2014-05-23 10:53 GMT+03:00 Markus Svensson 
<markus.svens...@me.com<mailto:markus.svens...@me.com>>:
Hi,

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...).

Feel free to have a look at how I implemented it: 
https://github.com/Ortofta/SilicaNote

The code quality is probably not the best - these are my first baby steps in QT 
and Sailfish. ;)

Regards,
Markus


23 maj 2014 kl. 08:52 skrev Kimmo Lindholm 
<kimmo.lindh...@eke.fi<mailto:kimmo.lindh...@eke.fi>>:

Hi,,

Thank you Janne and Jarko, I will take a look on both of these approaches;

> use the QSqlQueryModel in your c++ and expose that to QML ; just like in : 
> http://qt-project.org/wiki/How_to_use_a_QSqlQueryModel_in_QML


> subclassing QAbstractItemModel. See 
> http://qt-project.org/doc/qt-5/qtquick-modelviewsdata-cppmodels.html and 
> http://qt-project.org/doc/qt-5/qabstractitemmodel.html to get started.


-kimmo
_______________________________________________

SailfishOS.org<http://SailfishOS.org> Devel mailing list
To unsubscribe, please send a mail to 
devel-unsubscr...@lists.sailfishos.org<mailto:devel-unsubscr...@lists.sailfishos.org>

_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to 
devel-unsubscr...@lists.sailfishos.org<mailto:devel-unsubscr...@lists.sailfishos.org>


_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Reply via email to