Partially bold text in a QListWidgetItem
I would like to know what's the best way to just have partially bold text (single bold words) in a QListWidgetItem.
I tried with delegate, drawing normal text, then bold text, then normal text again... but had problems with positioning the blocks of text in sequence.
I also tried with showing a QTextDocument per row, but this seems a bit of an overkill, I just need a bold word per row.
It doesnt matter how the bold text is defined, could be "text<boldtext>text" or with html tags, nevermind. It should just work :)
Thank you in advance!
There is no way that "just works". I once wrote a rich text delegate that basically used a QTextDocument per cell, and a later version even used webkit to render a cell (so it could support CSS to a much larger extend). Overkill? Perhaps, but at least it worked. I gave it up though, because I could not find a way to make the items properly styled as well. The way QStyledItemDelegate works with rendering is just not all that convenient.
I just tried with a QLabel with rich text for a row. Then I set the label as item widget: listWidget->setItemWidget
Seems to "just work" :) But havent thoroughly tested it yet...
Putting widgets in there is even more expensive, and harder to manage. I used QTextDocument::drawContents(), and kept the textdocuments in a cache.