Hey,
I am not sure how to use the setData() method in my custom model. It seems to be, that the data is changed well, but the view is not updated since i clicked with the mouse on some other widgets. I am not sure how to handle the emit dataChanged() OR reset() methods...
Anyone who can help me ?

Qt Code:
  1. bool SchulungsplanModel::setData(const QModelIndex &index, const QVariant &value, int role)
  2. {
  3. if (index.isValid() && role == StartKursRole)
  4. {
  5. int puVectorIndex = findKursByRowValue(index.row()).at(0);
  6. int kurseVectorIndex = findKursByRowValue(index.row()).at(1);
  7.  
  8. QDate myCurrentCellDate = whereInTheDateAmI(index.column() );
  9. QDate startKursDate = m_spData.getPUs()[puVectorIndex].getPUKurse()[kurseVectorIndex].getStartKursDatum();
  10. QDate endKursDate = m_spData.getPUs()[puVectorIndex].getPUKurse()[kurseVectorIndex].getEndKursDatum();
  11.  
  12. bool dateBetweenCourseDate = isTheDateBetween( myCurrentCellDate, startKursDate, endKursDate);
  13.  
  14. if (dateBetweenCourseDate == true)
  15. {
  16. qDebug() << "startKursDatum: value.toDate().toString(): " << value.toDate().toString("dd.MM.yyyy");
  17. m_spData.getPUs()[puVectorIndex].getPUKurse()[kurseVectorIndex].setStartKursDatum(value.toDate());
  18. qDebug() << "startKursDatum changed in:" << m_spData.getPUs()[puVectorIndex].getPUKurse()[kurseVectorIndex].getStartKursDatum().toString("dd.MM.yyyy");
  19. }
  20. emit dataChanged(index, index);
  21. //reset();
  22. return true;
  23. }
To copy to clipboard, switch view to plain text mode