if you use some of QSql*Model then you should approach which estanisgeyer suggested of write your own delegate.
an exmaple
{
public:
public:
{
drawBackground(painter, option, index);
}
protected:
{
Q_UNUSED(index);
painter
->fillRect
(option.
rect,
QColor(qrand
()%255, qrand
()%255, qrand
()%255
));
}
};
class ColorDelegate: public QItemDelegate
{
public:
ColorDelegate(QObject *parent = 0) : QItemDelegate(parent) {}
public:
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
drawBackground(painter, option, index);
QItemDelegate::paint(painter, option, index);
}
protected:
virtual void drawBackground(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(index);
painter->fillRect(option.rect, QColor(qrand()%255, qrand()%255, qrand()%255));
}
};
To copy to clipboard, switch view to plain text mode
applying a delegate for a table
...
table->setItemDelegate(new ColorDelegate(table));
...
...
table->setItemDelegate(new ColorDelegate(table));
...
To copy to clipboard, switch view to plain text mode
but in this case when a table is being resized items colors is being changed to.
Bookmarks