1

I'm trying to display some items in a QListView with some simple text formatting changes.

My list items are dictionary entries. The word is bold. The definition is not:

  • the word: the definition
  • another word: another definition

From reading the documentation, I see I need to create a custom delegate which I started to do but I think I'm doing something wrong. Using QItemDelegate, it looks like there's an awful lot of behavior that I need to replicate for this simple modification.

Is there a way to subclass from QItemDelegate in such a way that I'm not duplicating so much code?

Edit after searching some more, I found this answer

Community
  • 1
  • 1
mmccoo
  • 8,386
  • 5
  • 41
  • 60

1 Answers1

2

It is recommended by the documentation to use a QStyledItemDelegate. Easier would be to use a QListWidget and to set the items to QLabels with setItemWidget and to use RichText in the QLabels.

hmuelner
  • 8,093
  • 1
  • 28
  • 39