QListView with custom item delegate
-
I am using a
QListView
with a customQAbstractItemModel
to display messages I parsed from a compiler output. Looks like this:However, I'd like to have a bit more control over the text styles. For example, I'd like to use two different fonts within the same item and also different font colors. The
QAbstractItemModel
itself is not capable of handling this. From previous experiences withQTreeView
andQTableView
I would have thought that I simply write my own customQStyledItemDelegate
that takes care of the painting of the widget. However, it seems thatQListView
doesn't allow setting custom item delegate. Is that correct? If so, why? And how can I still archive what I want? -
@Joel-Bodenmann said:
I would have thought that I simply write my own custom QStyledItemDelegate that takes care of the painting of the widget.
I would've thought so too.
However, it seems that QListView doesn't allow setting custom item delegate. Is that correct? If so, why?
Hm, is QAbstractItemView::setItemDelegate not working?
-
@kshegunov said:
Hm, is QAbstractItemView::setItemDelegate not working?
Oh god... I'm a completely retarded idiot. I was going through the API of the
QListView
and in the complete brain-dead mode I must have been I forgot to check the base classes...I'm sorry for the trouble!
-
Sometimes it's hard to track down inherited members from the base page of the class. When you're in doubt you can go to the "List of all members, including inherited members" page. ;)