Hi, just wanted to say a big thank you for solving this.

It now takes 0 seconds to display 30,000 rows in the TableView, by subclassing an AbstractTableModel.
I am now starting to understand the power of a MVC design!

I never thought it would work but wow, its fast.

Below is some code in case it helps someone to do the same:

Qt Code:
  1. int ResultsModel::rowCount(const QModelIndex &parent) const
  2. {
  3. filteredResults.size();
  4. }
  5.  
  6.  
  7.  
  8. int ResultsModel::columnCount(const QModelIndex &parent) const
  9. {
  10. return 13;
  11. }
  12.  
  13.  
  14.  
  15.  
  16. QVariant ResultsModel::data(const QModelIndex &index, int role) const
  17. {
  18.  
  19. QVariant data;
  20.  
  21. if (!index.isValid()) {
  22. return QVariant();
  23. }
  24.  
  25. if (index.row() >= filteredResults.size()) {
  26. return QVariant();
  27. }
  28.  
  29. if (index.column() >= 13) {
  30. return QVariant();
  31. }
  32.  
  33. if (role == Qt::DisplayRole) {
  34. int db = mainBoard->filteredResults[index.row()]->dbIndex;
  35. int game = mainBoard->filteredResults[index.row()]->gameIndex;
  36. boost::shared_ptr<Game> gamePtr = mainWindow_->dbManager_->databases[db]->database->Games[game];
  37.  
  38. switch (index.column()) {
  39. case 0 : {
  40. data = (mainWindow_->dbManager_->databases[db]->name).c_str();
  41. return data;
  42. }
  43. case 1 : {
  44. data = (gamePtr->getPlayerW()).c_str();
  45. return data;
  46. break;
  47. }
  48. case 2 : {
  49. data = (gamePtr->getPlayerB()).c_str();
  50. return data;
  51. break;
  52. }
  53.  
  54. // ETC ETC
  55.  
  56. }
  57. }
  58. // else
  59. return QVariant();
  60. }
To copy to clipboard, switch view to plain text mode