{
QString currDescription
= index.
model()->data
(index, Qt
::DisplayRole).
toString();
QBrush backgroundBrush
= index.
model()->data
(index, Qt
::BackgroundRole).
value<QBrush>
();
QString dataDescription
= QString("%1 %2").
arg(globalVal, currDescription
);
myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
// none of these set the background color back to that of the index background role
// myOption.palette.setBrush(QPalette::Window, backgroundBrush);
// or
// myOption.palette.setBrush(QPalette::Base, backgroundBrush);
// or
painter->setBackground(backgroundBrush);
drawDisplay(painter, myOption, myOption.rect, dataDescription);
}
void JB_EntireTreeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QString currDescription = index.model()->data(index, Qt::DisplayRole).toString();
QBrush backgroundBrush = index.model()->data(index, Qt::BackgroundRole).value<QBrush>();
QStyleOptionViewItem myOption = option;
QString dataDescription = QString("%1 %2").arg(globalVal, currDescription);
myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
// none of these set the background color back to that of the index background role
// myOption.palette.setBrush(QPalette::Window, backgroundBrush);
// or
// myOption.palette.setBrush(QPalette::Base, backgroundBrush);
// or
painter->setBackground(backgroundBrush);
drawDisplay(painter, myOption, myOption.rect, dataDescription);
}
To copy to clipboard, switch view to plain text mode
Bookmarks