C++ (Qt)QVariant data(const QModelIndex &index,int role = Qt::DisplayRole) const{ QVariant value = QSqlQueryModel::data(index, role); switch (role){ case Qt::BackgroundRole: if(this->data(this->index(index.row(),3)).toInt() == 1) return QColor(212,208,200,225); case Qt::FontRole: if(this->data(this->index(index.row(),3)).toInt() == 1) return QFont::Bold; } return value; }
Variant data(const QModelIndex &index,int role = Qt::DisplayRole) const{ QVariant value = QSqlQueryModel::data(index, role); switch (role){ case Qt::BackgroundRole: if(this->data(this->index(index.row(),3)).toInt() == 1) return QColor(212,208,200,225); case Qt::FontRole: if(this->data(this->index(index.row(),3)).toInt() == 1) { QFont font = QParentModel::data(index, role);// QParentModel - имя суперкласса модели; font.setWeight (QFont::Bold); return font; } } return value; }
C++ (Qt) case Qt::BackgroundRole: if(this->data(this->index(index.row(),3)).toInt() == 1) return QColor(212,208,200,225); case Qt::FontRole: