title: QTableView slow performance with 1000s of visible cells
body: <p>I'm using QTableView in Qt 4.8.4 to visualize a lot of data (large/many protein amino acid sequences) and I'd like to be able to make cells as small as possible so I can pack as many as possible into a given window. The problem I'm running into is that when there are many cells displayed at once, everything (e.g. scrolling, resizing, and in general repainting) slows down to a crawl. Here's some sample code (adapted from the examples/tutorials/1_readonly tutorial):</p>
  
  <pre><code>MyModel::MyModel(QObject *parent):QAbstractTableModel(parent){}
  
  int MyModel::rowCount(const QModelIndex &amp; /*parent*/) const {
     return 200;
  }
  int MyModel::columnCount(const QModelIndex &amp; /*parent*/) const {
      return 60;
  }
  QVariant MyModel::data(const QModelIndex &amp;index, int role) const {
      if (role == Qt::DisplayRole){
         return QString("%1").arg(index.row()%10);
      }
      return QVariant();
  }
  </code></pre>
  
  <p>and here's the code which runs the table view:</p>
  
  <pre><code>int main(int argc, char *argv[]){
     QApplication a(argc, argv);
     QTableView tableView;    
     tableView.horizontalHeader()-&gt;setDefaultSectionSize(15);
     tableView.verticalHeader()-&gt;setDefaultSectionSize(15);
     tableView.setFont(QFont("Courier",12));
     MyModel myModel(0);
     tableView.setModel( &amp;myModel );
     tableView.setGeometry(0,0,1000,1000);
     tableView.show();
     return a.exec();
  }
  </code></pre>
  
  <p>When I use Instruments on OSX while scrolling up and down, it's spending a lot of time in <code>QWidgetPrivate::drawWidget</code> and down the stack, <code>QWidgetPrivate::paintSiblingsRecursive</code>... i.e., it's spending a lot of time redrawing my table.</p>
  
  <p>I'm new to Qt, so I'm not sure how to approach this problem. Should I:</p>
  
  <ul>
  <li>override the paint method? i.e. perhaps I could save my whole table as an image, and when scrolling happens, to just repaint the image until movement stops (and then return to painting the table directly)?</li>
  <li>Not use tables in Qt at all? Perhaps I can just use a Text field to accomplish my purposes? e.g. for each letter in the text, i'd like hovertext, selections, coloring letter's backgrounds, etc.</li>
  </ul>
  
  <p>Both of these options seem like a lot of work to make up for ground lost by switching away from QTableView. Are there any other suggestions?</p>