Can't expose QStringList to custom component TableView
-
I'm using the custom component TableView with one column and would like to use a QStringList in C++ to manage its elements.
This example shows how to do this for a ListView : http://doc.trolltech.com/4.7-snapshot/declarative-modelviews-stringlistmodel.html
That works for me.In my main.cpp I've got the following code:
@ QStringList dataList;
dataList.append("Item 1");
dataList.append("Item 2");
dataList.append("Item 3");
dataList.append("Item 4");context->setContextProperty("myModel", QVariant::fromValue(dataList));@
In my main.qml I use it like this:
@
TableView{HeaderSection { property: "title" caption: "Track" width: 200 } model: myModel width: 200 height: 100 itemDelegate: Rectangle { height: 25 width: 100 Text { text: modelData } } }@
I get these two errors for every element I'm adding:
@qrc:/desktop-components/components/TableView.qml:278: TypeError: Result of expression 'root.model.get' [undefined] is not a function.
qrc:/qml/MyProject/main.qml:239: ReferenceError: Can't find variable: modelData@Why can't I use the QStringList.
The source of Tableview.qml can be found here:
http://qt.gitorious.org/qt-components/desktop/blobs/master/components/TableView.qml -
I don't know but I am pretty certain the property your headersection should bind to is called "text" and not "title".