Ok, I understand.
I think QSqlTableModel was used because it enables changing the color of items, re-writing the data function.
{
if ( role == Qt::TextColorRole )
if( (index.column(), index.row()) )
return value;
}
QVariant SqlTableModelTk::data(const QModelIndex &index, int role) const
{
QVariant value = QSqlTableModel::data(index, role);
if ( role == Qt::TextColorRole )
if( (index.column(), index.row()) )
return QVariant::fromValue(QColor(Qt::red));
return value;
}
To copy to clipboard, switch view to plain text mode
As it doesn't exist a data function for QSqlQueryModel then I suppose I'm in the correct direction. Is there another approach which could be applied in order to attend both requirements, change item color and prevent editing the database?
Thanks for the attention.
Bookmarks