{
// if i did nothing in this function, the items are draw by the view? since they are still draw as the style sheet
if (index.data(Qt::UserRole).toBool())
{
QStyledItemDelegate::paint(painter, option, index);
}
else
{
// here, i wonder how to change the option to change the style of this item, for example, i hope this item has the same border and font as others, but different background-color, however, this does not work:
another_option.
palette.
setColor(QPalette::Background,
QColor(Qt
::yellow));
}
}
CustomDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index)const
{
// if i did nothing in this function, the items are draw by the view? since they are still draw as the style sheet
if (index.data(Qt::UserRole).toBool())
{
QStyledItemDelegate::paint(painter, option, index);
}
else
{
QStyleOption another_option(option);
// here, i wonder how to change the option to change the style of this item, for example, i hope this item has the same border and font as others, but different background-color, however, this does not work:
another_option.palette.setColor(QPalette::Background, QColor(Qt::yellow));
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks