maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [Help needed] SectionScroller QML and QList<QObject*> (https://talk.maemo.org/showthread.php?t=88910)

marmistrz 2013-02-01 14:00

[Help needed] SectionScroller QML and QList<QObject*>
 
Hi,

I'd like to use QML SectionScroller with a QList<QObject*> based model.
My ListView's section configuration is:

Code:

section.criteria: ViewSection.FirstCharacter
section.property: "form0"

Where form0 property is valid and displayed in the view delegate

When the SectionScroller is inserted to the QML code, I'm getting an error:

Code:

.../com/nokia/meego/SectionScroller.qml:319: Error: cannot assign [undefined] to QString
What am I doing wrong? I'd prefer to avoid QAbstractListModel, as I think it'd be an overkill right there - the elements are like this:

Code:

class IrregularVerb : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString form0 READ getForm0 NOTIFY formChanged)
    Q_PROPERTY(QString form1 READ getForm1 NOTIFY formChanged)
    Q_PROPERTY(QString form2 READ getForm2 NOTIFY formChanged)
// internal stuff there
};

Thanks

marmistrz 2013-02-02 19:06

Re: FastScroll/SectionScroller QML and QList<QObject*>
 
Updated the opening post

gionni88 2013-02-03 10:38

Re: [Help needed] SectionScroller QML and QList<QObject*>
 
You need a QAbstractListModel with the following implementations to be able to use section scrollers or fast scroll:

//the number of total items property...
Q_PROPERTY(int count READ rowCount)

//... and its read method implementation
Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const;

//a get method
Q_INVOKABLE Element* get(int index)




If you think it's an overkill, you may set a class which emits the items in your list and a qml listmodel to capture them. If the items are a lot, hovewer, it will slow down a lot your UI thread.

In my opinion a correct QAbstractListModel is far better, it gives you more features and you can expand it at needs.


All times are GMT. The time now is 03:05.

vBulletin® Version 3.8.8