@VRonin
I am trying to do this. I am a newbiew, so need your assistance. Hope you can understand. Here are some rough code.
MediaFileItemDelegate::MediaFileItemDelegate(QObject *parent) :QStyledItemDelegate(parent)
{
}
MediaFileItemDelegate::~MediaFileItemDelegate()
{
}
void MediaFileItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,const QModelIndex& index) const
{
QString str = qvariant_cast<QString>(index.data());
painter->save();
painter->setPen(Qt::NoPen);
// painter->drawRect(option.rect);
if(index.data().toString().contains("xyz"))
{
painter->setPen(Qt::blue);
painter->drawText(option, str);
}
else
{
QStyledItemDelegate::paint(painter, option, index);
}
painter->restore();
}
Currently this code is highlighting the whole text (example: My name is xyz) and I am doing manually matching. So how can i select only xyz. Thanks