EDIT: 26.08.2014 08:20 - Completely reworked question!
What I want to do is:
- Fill a qml-listview with data from a cpp-listmodel (QAbstractListModel).
- Open a Dialog that show's more data from the cpp-listmodel by click on a listview-item.
I have two cpp-Classes:
- DataModelItem with two attributes (listData (displayed in the listview) and detailsData (displayed in the Dialog))
- DataModel which inherits QAbstractListModel with an attribut QList itemList.
DataModel.cpp:
QVariant DataModel::data(const QModelIndex &index, int role) const
{
DataModelItem *item = m_itemList.at(index.row());
switch (role) {
case ListDataRole:
return QString().sprintf("%.2f", item->listData());
break;
case DetailsDataRole:
return QString().sprintf("%.4f", item->detailsData());
break;
default:
qDebug () << "role not handled";
}
return QVariant();
}
What I now wanna do is, to display the listData in the ListView. When I click on one ListItem a dialog should appear with the detailsData.