I have subclasses the QAbstractTableModel
and provided the headerData
override:
/**
* @brief Obtains the header (columns) names.
* @param section: column number.
* @param orientation: Accepts only horizontal.
* @param role: Accepts only display.
* @return The column header text in case all params are valid.
* Otherwise empty QVariant.
*/
QVariant CVarTableModel::headerData(int section,
Qt::Orientation orientation,
int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (orientation != Qt::Horizontal)
return QVariant();
if (section >= static_cast<int>(Columns::ZCOUNT))
return QVariant();
return QVariant::fromValue(static_cast<Columns>(section));
}
I am trying to figure out how to make my QML TableView
component utilize this function. Is there a way to do this automatically?