I tried what was suggested in the link, but it doesn't work, i.e. the newly calculated row doesn't show, even though I inserted the new column in my instance of my custom model (based on QSqlRelationalTableModel).
my data method looks like this:
{
if(role == Qt::TextAlignmentRole && (index.column() == 4 || index.column() ==5 || index.column() == 6))
value
= QVariant(Qt
::AlignRight | Qt
::AlignVCenter);
else if(role == Qt::DisplayRole && index.column() == 7)
{
}
else
return value;
}
QVariant CustomModel::data(const QModelIndex &index, int role) const
{
QVariant value = QSqlRelationalTableModel::data(index,role);
if(role == Qt::TextAlignmentRole && (index.column() == 4 || index.column() ==5 || index.column() == 6))
value = QVariant(Qt::AlignRight | Qt::AlignVCenter);
else if(role == Qt::DisplayRole && index.column() == 7)
{
QModelIndex mi = this->index(index.row(),4,QModelIndex());
value = QVariant(mi.data(role)) ;
}
else
value = QSqlRelationalTableModel::data(index, role);
return value;
}
To copy to clipboard, switch view to plain text mode
what am I missing?
Bookmarks