How to set several fonts for one Qstandarditem (different fonts for parts of text)
Hi, i use PyQT5, i have a QStandardItemModel in which i appendRows, which consist of QStandardItems.
One of this QStandardItem consists of data, part of which i want to highlight (add bold or strikeout or another color).
This data part is a unique id which i will find with regexp.
So the main question is how to add some styling to only PART of DATA (not the whole cell, not whole QStandardItem, but only part of its text).
Thanks in advance.
Re: How to set several fonts for one Qstandarditem (different fonts for parts of text
You can try creating the string using Rich Text Format, but if QTableView or whatever you are using to display your model doesn't support it, then you are out of luck. Your only option at that point is to derive a QStyledItemDelegate that supports Rich Text and install that on the appropriate column(s) of your view.
Here's a StackOverflow question with both C++ and Python implementations you might be able to adapt. (See the answers, not the original question).