I have 2 tableViews that inherit from the same class (TableModel) which in turn inherits from QAbstractTableModel. I would like to add headers for the 2 tables but these headers should be different for each table. In my TableModel I have this method:
QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (orientation == Qt::Horizontal) {
switch (section) {
case 0:
return tr("Header1");
case 1:
return tr("Header2");
case 2:
return tr("Header3");
default:
return QVariant();
}
}
return QVariant();
}
But that will only work for one of the tables. How could I set different headers for the other table?