Hi,
I need a good source to understand how Qt::Foreground Role works with tableview. I just want to change text color depend on the one column value.
Any body has good reading pages.
Hi,
I need a good source to understand how Qt::Foreground Role works with tableview. I just want to change text color depend on the one column value.
Any body has good reading pages.
Please try adding the following to data() changes text colour for a cell or row:
QVariant CustomSqlModel::data(const QModelIndex &index, int role) const
{
QVariant value = QSqlQueryModel::data(index, role);
if (role == Qt::ForegroundRole && index.column() == 1)
return qVariantFromValue(QColor(Qt::blue));
return value;
}