calculated columns for QSqlRelationalTableModel
I'm working on an app for a MySQL db. One of the tables features 3 columns that I'd like to sum up per row and then a subtotal for all rows for those 3 columns.
I managed to get the column subtotals, but for the row total (for the 3 fields of that particular row), I would need a calculated field.
After googling, the only reference I could find is this thread:
http://lists.trolltech.com/qt-intere...ad00142-0.html
would that be the best way to approach this or is it possible to change the underlying SQL for the QSqlRelationalTableModel?
cheers,
-A
Re: calculated columns for QSqlRelationalTableModel
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:
Code:
{
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;
}
what am I missing?