We have a very complicated custom coloring scheme for a delegate in a QTableWidget. We do need the SelectionModel though, so setSelectionMode(QAbstractItemView::NoSelection) is not an option.
I tried to overwrite the paint function like this:
{
QStyleOptionViewItemV4 noSelectionOption(option);
initStyleOption(&noSelectionOption, index);
noSelectionOption.showDecorationSelected = false;
QStyledItemDelegate::paint(painter, noSelectionOption, index);
}
void LineEditDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItemV4 noSelectionOption(option);
initStyleOption(&noSelectionOption, index);
noSelectionOption.showDecorationSelected = false;
QStyledItemDelegate::paint(painter, noSelectionOption, index);
}
To copy to clipboard, switch view to plain text mode
But the Texts in the cells are still drawn with blue background and white foreground.
How can I fix this?
Bookmarks