[Qt-qml] QValueList inside model ?
Helio Chissini de Castro
helio at kde.org
Thu Oct 14 23:02:26 CEST 2010
Answering myself thanks to Adriano:
To access that VariantList members, modelData is needed.
So, all members must be acessed as modelData.<member>
Not clear to find, but fits the solution
[]'s
Em quarta-feira 13 outubro 2010, às 07:04:42, Helio Chissini de Castro escreveu:
> Hi.
>
> I have this example situation, a object model that contains at least onw QVariantList, like this
>
> class LocalModel : public QObject {
> Q_OBJECT
> Q_PROPERTY(QString name READ name)
> Q_PROPERTY(QVariantList list READ list)
>
> ...
> public:
> QVariantList list() const { return m_list; }
> QString name() const { return m_name; }
> private:
> QVariantList m_list;
> QString m_name;
> };
>
>
> In the cpp file i set the context property as usual, and can use name as a regular member in qml, like
> cpp:
> ctxt->setContextProperty( "myData", theObjectModel);
>
> qml:
> Text { text: name }
>
>
> But, how can i use the list ?
> I tried with no luck this:
> ListView {
> delegate: Text { text: mytextinsidelist }
> model: list
> }
>
> Any idea how can use the QVariantList as a model ?
>
> []'s
>
>
--
Helio Chissini de Castro
South America and Brazil Primary Contact
KDE Developer since 2002
More information about the Qt-qml
mailing list