I'm using a table view with a custom table model derived from QAbstractTableModel. The table's vertical header should be hidden, but the horizontal one should be showing.

My table model (MyModel) implements ::headerData returning a simple QString variant for the header.

It is getting called, but the header won't show up. Any idea why?

I'm creating the view in the following way:

Qt Code:
  1. QTableView *view = new QTableView;
  2.  
  3. view->setSortingEnabled(true);
  4. view->setSelectionBehavior(QAbstractItemView::SelectRows);
  5. view->setEditTriggers(QAbstractItemView::NoEditTriggers);
  6. view->setSelectionMode(QAbstractItemView::SingleSelection);
  7. view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  8. view->setShowGrid(false);
  9. view->setModel (new MyModel(this));
  10. view->setCurrentIndex(QModelIndex());
  11. view->horizontalHeader()->setStretchLastSection(true);
  12. view->verticalHeader()->hide();
To copy to clipboard, switch view to plain text mode 

Thanks,
Susan