I'm having problems, show Qicon in rows.
now:
I would like to show:
my code. But the icon does not appear and there is no compiler error:
c
lass MySubClassedSqlTableModel : public QSqlTableModel
{
Q_OBJECT
public:
MySubClassedSqlTableModel(QObject * parent = 0, QSqlDatabase db = QSqlDatabase())
: QSqlTableModel(parent,db) {;}
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const
{
if(role==Qt::BackgroundColorRole)
{
const QVariant value(data(index,Qt::DisplayRole));
if(value.toString()=="yes"){
return QIcon(":/img/icons/yes.png");
}else{
return QIcon(":/img/icons/no.png");
}
}
return QSqlTableModel::data(index,role);
}
};
Could someone help me?