QListWideget and QListWidgetItem
-
-
AFAIK there is no way to use delegates with QListWidget (or QTableWidget / QTreeWidget).
You can only customize your items with the properties QListWidgetItem has.
If you want to do more, you'll have to use QListView with either QStandardItemModel or your own implementation of QAbstractItemModel. Then you can use QAbstractItemView::setItemDelegate() -
[quote author="Gerolf" date="1351064579"]The answer depends on what you like to change. If you want to change only colors (like background, text color) it can be done via properties of the items. If you want a complete custom drawing (like gradients, or whatever), you must use a delegate.[/quote]
thanks. I have to draw an icon and a text. Text should be vertical aligned with the icon. Any idea? I have alerady a QStyledItemDelegate, I was just wandering what is better
-
Icons can be added as decoration role, the you have icon and text side by side (typically icon on the left).
Otherwise the delegate has a paint method. Overwrite it and do, what is needed there.@Mr.Universe: QListWidget is a QListView and you can use delegates for them, just not own models.