I'd like to know how do I add a tableView
to the background
and icone
property? I can already add the Background
is now missing the icon.
Code:
class tableView : public QSqlTableModel
{
Q_OBJECT
public:
tableView(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()=="Sim"){
return QVariant(QColor("#d0ffe3")); //<<background
}else if (value.toString()=="Não"){
return QVariant(QColor("#ffe3d0")); //<<background
}else if (value.toString()=="Neutro"){
return QVariant(QColor("#fffad0")); //<<background
}
}
return QSqlTableModel::data(index,role);
}
};