I need to implement something like this...
Qt Code:
  1. QVariant MsgStatsModel::data(const QModelIndex &index, int role) const
  2. {
  3.  
  4. QVariant ret;
  5.  
  6. if(!index.isValid()){
  7. std::cout <<"Invalid Index of data provided!"<< std::endl;
  8. return ret;
  9. }
  10.  
  11. int row = index.row();
  12. int col = index.column();
  13.  
  14. if(row >= 0 && row < rowCount()) {
  15. if(role == Qt::DisplayRole) {
  16. //get the OBJECT stored on "row"
  17. switch(col) {
  18. case 0 :
  19. ret = QVariant(/*HERE THE ID MUST BE RETURNED*/);
  20. break;
  21. case 1:
  22. ret = QVariant(/*HERE THE COUNT OF THE ID MUST BE RETURNED*/);;
  23. break;
  24. }
  25. }
  26. }
  27. return ret;
  28. }
To copy to clipboard, switch view to plain text mode