Rocken
14th March 2012, 10:26
I want / have to write a setData() function in a class derived from QAbstractListModel because I want to modify the variable QList<ListItem*> m_list
in the QList I save Parameter-Objects with have a value property which can be written by calling setValue()
I tried the following lines in setData without success:
bool ListModel::setData(const QModelIndex &index, const QVariant &value, int role) {
Parameter item = *m_list[index.row()];
item.setValue(value.toString());
AND
m_list.at(index.row())->setValue(value.toString);
emit dataChanged(index,index);
return true;
}
Why is it not possible to get a Parameter object by reference and call the function setValue()?
in the QList I save Parameter-Objects with have a value property which can be written by calling setValue()
I tried the following lines in setData without success:
bool ListModel::setData(const QModelIndex &index, const QVariant &value, int role) {
Parameter item = *m_list[index.row()];
item.setValue(value.toString());
AND
m_list.at(index.row())->setValue(value.toString);
emit dataChanged(index,index);
return true;
}
Why is it not possible to get a Parameter object by reference and call the function setValue()?