[SailfishDevel] Technical question: populating ListModel from C++
Jarko Vihriala
jarko.vihriala at jolla.com
Fri May 23 08:23:40 UTC 2014
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-bounces at lists.sailfishos.org [devel-bounces at lists.sailfishos.org] on behalf of Mikko Leppänen [mleppan23 at 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.svensson at me.com<mailto:markus.svensson at 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.Lindholm at eke.fi<mailto:Kimmo.Lindholm at 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-unsubscribe at lists.sailfishos.org<mailto:devel-unsubscribe at lists.sailfishos.org>
_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org<mailto:devel-unsubscribe at lists.sailfishos.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20140523/9d9201d4/attachment.html>
More information about the Devel
mailing list