[Qt-qml] QValueList inside model ?

Helio Chissini de Castro helio at kde.org
Wed Oct 13 12:04:42 CEST 2010


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