Got it working thanks
For those interested my code:
in the .h file add:
{
Q_OBJECT
public:
};
class Delegate : public QItemDelegate
{
Q_OBJECT
public:
Delegate(QWidget *parent = 0) : QItemDelegate(parent) {}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
};
To copy to clipboard, switch view to plain text mode
in the .cpp, in a constructor
table->setItemDelegate(new Delegate);
table->setItemDelegate(new Delegate);
To copy to clipboard, switch view to plain text mode
and the event:
//---------------------------------------------------
{
if (qVariantCanConvert<QString>(index.data()))
val = qVariantValue<QString>(index.data());
if (val == "1")
{
painter->fillRect(option.rect, option.palette.highlight());
}
else
}
//---------------------------------------------------
void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QString val;
if (qVariantCanConvert<QString>(index.data()))
val = qVariantValue<QString>(index.data());
if (val == "1")
{
painter->fillRect(option.rect, option.palette.highlight());
}
else
QItemDelegate::paint(painter, option, index);
}
To copy to clipboard, switch view to plain text mode
Bookmarks