I assume your setting columnCount? Heres a snippet from my model that works:
int TableDetailModel
::columnCount(const QModelIndex &parent
) const {
Q_UNUSED(parent);
return 2;
}
QVariant TableDetailModel
::headerData(int section, Qt
::Orientation orientation,
int role
) const {
if (role != Qt::DisplayRole)
if (orientation == Qt::Horizontal) {
switch (section) {
case 0:
return tr("Id");
case 1:
return tr("Description");
default:
return "Unknown!";
}
}
}
int TableDetailModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 2;
}
QVariant TableDetailModel::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("Id");
case 1:
return tr("Description");
default:
return "Unknown!";
}
}
return QVariant();
}
To copy to clipboard, switch view to plain text mode
Bookmarks