I have sucessfully implemented a Table/Model view by subclassing QTableView and QAbstractTableModel. All adding, sorting and removal of table data is working great. However, I am trying to figure out how to hide a row in the table using the setRowHidden( ) fucntion. I have setup a structure in the TableModel to flag if the row is hidden or not, but the data( ) function returns a empty QVariant( ) if the cell is supposed to be hidden.
The data is stored in a 2D Vector for easy sorting. I am using a struct with a QVariant, QColor, and bool shown (hidden/not hidden) to store the data attributes. Here is the code from the data( ) function. Please ignore any obvious mistakes, I typed this in from memory since I dont have access to the code at home!

Qt Code:
  1. QVariant StringListModel::data(const QModelIndex &index, int role) const
  2. {
  3. if (!index.isValid())
  4. return QVariant();
  5.  
  6. int row = index.row();
  7. int column = index.column();
  8.  
  9. if (role == Qt::DisplayRole) {
  10. if( mDataModel[row][column].shown == false )
  11. return QVariant(); // <==== Return somthing other than QVariant( )???
  12. else
  13. QString str;
  14. switch( mDataModel[row][column].data.type( ) )
  15. {
  16. case QVariant::Double:
  17. str = QString::sprintf( "%12.6g", mDataModel[row][column].data.toDouble( )
  18. case QVariant::Int:
  19. str = QString::sprintf( "%12d", mDataModel[row][column].data.toInt( ) );
  20. default:
  21. str = mDataModel[row][column].data.toString( );
  22.  
  23. return str;
  24. }
  25. else if (role == Qt::BackgroundColorRole ) {
  26. return mDataModel[row][column].color;
  27. }
  28.  
  29. return QVariant( );
  30. }
To copy to clipboard, switch view to plain text mode 

What I am asking is if there is an easy way to not display the data row in an Model without completly removing the entries?

Thanks