Hello!!
I'm trying show a class inherent of QStandardItemModel in listView of QML, as follow:
main.cpp
QDeclarativeView view;
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", w.getModel());
QDeclarativeView view;
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", w.getModel());
To copy to clipboard, switch view to plain text mode
main.qml
import QtQuick 1.1
Rectangle
{
width: 240; height: 200
ListView
{
width: 240; height: 200
model: myModel
delegate:
Text {
text: " - " + display //is roles[Qt::DisplayRole] = "display"
}
}
import QtQuick 1.1
Rectangle
{
width: 240; height: 200
ListView
{
width: 240; height: 200
model: myModel
delegate:
Text {
text: " - " + display //is roles[Qt::DisplayRole] = "display"
}
}
To copy to clipboard, switch view to plain text mode
w.getModel() is a (QStandardItemModel*) that has a "list" of QStandardItem with childs, but in ListView of qml file, is only showing QStandardItem parents, How I can show all QStandardItem and childs in ListView? and by the other hand, Is posible pass a QItemDelegate to ListView ( Delegate: )?
Thanks!
Bookmarks