09-09-2012 07:08 AM
I would like to port a custom component that uses a QAbstractListModel. As items of this list, I used a QObject.
In the GroupDataModel docs is stated:
Each item in this model is a QVariantMap or a QObject*.
but I didn't understand well how to use my QObject as content of my list. Or maybe is better to use QListDataModel or something different to expose my list to QML ?
Thanks in advance
09-11-2012 02:39 PM - edited 09-11-2012 02:39 PM
If you are using a ListView, you need to use a subclass of DataModel.
(as per https://developer.blackberry.com/cascades/referenc
Your choices are one of the pre-defined ones, or roll your own.
09-14-2012 03:38 PM
Hi Stuart and thanks for your time.
I read the docs and the examples you gave me, but I still have problems to figure out how to achieve my goal with DataModel.
I see for example that I must reimplement
QVariant data (const QVariantList &indexPath)
and this function is meant to comunicate with QML requests as I understand.
Instead QAbstactListModel::data(const QModelIndex &index, int role) has also the role argument and with this I can know which role of which item its needed.
In my DataModel subclass I have a QList<myQObject *> and each myQObjects has roles like: url, downloadProgress, totalSize etc.
How should I know if the requested indexPath is downloadProgress of the 2nd QList item ?
About my example, I understood that all items of QList<myQObject *> are level 0 and the roles (url, downloadProgress, totalSize etc.) are level 1. Is this correct ?
thanks a lot