V
V
VitaliiUA2019-05-10 17:57:53
Qt
VitaliiUA, 2019-05-10 17:57:53

How to override setData() method of QSqlQueryModel to change text color?

Help to override the setData () method of QSqlQueryModel, so that it would be possible to change the color of the text

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SerJook, 2019-05-10
@SerJook

Derivate from the QSqlQueryModel class and override the data() method:

QVariant MyModel::data(const QModelIndex &index, int role) const {
  if(role == Qt::TextColorRole) {
    return QVariant(QColor(Qt::blue));
  }
  return QSqlQueryModel::data(index, role);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question