I need to implement something like this...
{
if(!index.isValid()){
std::cout <<"Invalid Index of data provided!"<< std::endl;
return ret;
}
int row = index.row();
int col = index.column();
if(row >= 0 && row < rowCount()) {
if(role == Qt::DisplayRole) {
//get the OBJECT stored on "row"
switch(col) {
case 0 :
ret
= QVariant(/*HERE THE ID MUST BE RETURNED*/);
break;
case 1:
ret
= QVariant(/*HERE THE COUNT OF THE ID MUST BE RETURNED*/);;
break;
}
}
}
return ret;
}
QVariant MsgStatsModel::data(const QModelIndex &index, int role) const
{
QVariant ret;
if(!index.isValid()){
std::cout <<"Invalid Index of data provided!"<< std::endl;
return ret;
}
int row = index.row();
int col = index.column();
if(row >= 0 && row < rowCount()) {
if(role == Qt::DisplayRole) {
//get the OBJECT stored on "row"
switch(col) {
case 0 :
ret = QVariant(/*HERE THE ID MUST BE RETURNED*/);
break;
case 1:
ret = QVariant(/*HERE THE COUNT OF THE ID MUST BE RETURNED*/);;
break;
}
}
}
return ret;
}
To copy to clipboard, switch view to plain text mode
Bookmarks