if (data.isValid() && item.column() == 4 && role == Qt::DisplayRole) { QImage image; if (data.toString() == QString("YES")) { image.load(":/images/ok.PNG","PNG"); } else if (data.toString() == QString("NO")) { image.load(":/images/no.PNG","PNG"); } return image; } if (data.isValid() && role == Qt::TextColorRole) { if (item.column() == 2) { return qVariantFromValue(QColor(Qt::blue)); } else if (item.column() == 3) { return qVariantFromValue(QColor(Qt::green)); } }
if (item.column() == 2) { return Qt::blue; } else if (item.column() == 3) { return Qt::green; }
if (item.column() == 2) { return QVariant(Qt::blue); } else if (item.column() == 3) { return QVariant(Qt::green); }
if (data.isValid() && item.column() == 4 && role == Qt::DecorationRole) { if (data.toString() == QString("YES")) { return QIcon(":/images/ok.PNG"); } else if (data.toString() == QString("NO")) { return QIcon(":/images/no.PNG"); } }
QVariant data(const QModelIndex &item, int role) const;
bool setData(const QModelIndex &item, const QVariant &value, int role = Qt::DisplayRole);Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const;
QVariant data=QSqlQueryModel::data(item,role);
if (role == Qt::TextColorRole) { if (item.column() == 2) { return QVariant(Qt::blue); } else if (item.column() == 3) { return QVariant(Qt::green); } }
if (item.column() == 4 && role == Qt::DecorationRole) { if (data.toString() == QString("YES")) { return QIcon(":/images/ok.PNG"); } else { return QIcon(":/images/no.PNG"); } }