[Qt-interest] selection problem in listview
Ivan Kharin
korsar.akvis at gmail.com
Wed Mar 3 11:53:38 CET 2010
> void YourDelegate::paint ( QPainter * painter, const
> QStyleOptionViewItem & option, const QModelIndex & index ) const
> {
> if (!index.isValid()) return;
> if (option.state & QStyle::State_Selected)
> option.palette.setColor(QPalette::Text, Qt::White);
> QStyledItemDelegate::paint(painter, option, index);
> }
You can't change option, passed by const reference.
Make temporary copy:
QStyleOptionViewItemV4 opt = option;
if (opt.state & QStyle::State_Selected)
opt.palette.setColor(QPalette::Text, Qt::White);
QStyledItemDelegate::paint(painter, opt, index);
--
Regards,
Ivan Kharin
More information about the Qt-interest-old
mailing list