Hello, i want to color a whole row using a custom delegate when a specific column contains a date bigger then a set date. What i can actually accomplish is just setting the background color of the cell ...
Atm the code looks like this:
{
if ( index.column() == 11 )
{
QVariant date
= index.
model()->data
(index, Qt
::DisplayRole);
if ( dt > compareDate )
{
if (option.
state & QStyle::State_Enabled) painter->fillRect(option.rect, Qt::green);
}
}
}
void Delegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if ( index.column() == 11 )
{
QDateTime compareDate = QDateTime::fromString("2010-01-01T23:59:59", Qt::ISODate);
QVariant date = index.model()->data(index, Qt::DisplayRole);
QDateTime dt = date.toDateTime();
if ( dt > compareDate )
{
if (option.state & QStyle::State_Enabled)
painter->fillRect(option.rect, Qt::green);
QItemDelegate::paint(painter, option, index);
}
}
QItemDelegate::paint(painter, option, index);
}
To copy to clipboard, switch view to plain text mode
can anybody help with row coloring?
Bookmarks