Hi,
I have a QTableModel with 5 columns, but when I return labels for more than 4 columns the horizontal headerview isn't shown at all. Here is a simple application to highlight the problem. Save it as main.cpp and compile it using qmake -project && qmake && make

Qt Code:
  1. #include <QtGui>
  2.  
  3. class TableModel : public QAbstractTableModel
  4. {
  5. Q_OBJECT
  6. public:
  7. TableModel(QObject* parent = 0) : QAbstractTableModel(parent)
  8. {
  9. }
  10. protected:
  11. protected:
  12. int rowCount(const QModelIndex & parent = QModelIndex()) const
  13. {
  14. return 20;
  15. }
  16.  
  17. int columnCount(const QModelIndex & parent = QModelIndex()) const
  18. {
  19. return 5;
  20. }
  21.  
  22. QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const
  23. {
  24. if (index.isValid() && role == Qt::DisplayRole) {
  25. return QString("index: %1,%2").arg(index.row()).arg(index.column());
  26. }
  27. return QVariant();
  28. }
  29.  
  30. QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
  31. {
  32. if (orientation == Qt::Horizontal) {
  33. switch(section) {
  34. case 0: return QString("one");
  35. case 1: return QString("two");
  36. case 2: return QString("three");
  37. case 3: return QString("four");
  38. case 4: return QString("five");
  39. }
  40. }
  41. return QVariant();
  42. }
  43. };
  44.  
  45. int main(int argc, char** argv)
  46. {
  47. QApplication app(argc, argv);
  48. TableModel* model = new TableModel();
  49. QTableView* view = new QTableView;
  50. view->setModel(model);
  51. view->show();
  52. return app.exec();
  53. }
  54. #include "main.moc"
To copy to clipboard, switch view to plain text mode 
Any Ideas?

Thanx in advance
momesana