I'm having some difficulty adding a delegate to my QTreeView. I have added some QStandardItems through a model which works fine, but when I add the delegate, the text is erased and only the icons are visible.
This is the code i'm using for my delegate:
void SeqNavDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == 0 && option.state & QStyle::State_Enabled)
{
const QIcon icon(QLatin1String(":/SeqNavMenu/images/green.png"));
QRect iconRect(option.rect.right() - option.rect.height(),
option.rect.top(),
option.rect.height(),
option.rect.height());
icon.paint(painter, iconRect, Qt::AlignRight);
}
}
What i would like to do is combine the two, which is to say, have the text and checkboxes, and to the right have the icons that i have put in the delegate.
Maybe someone can point me in the right direction here ?
Cheers.