Does QListView support an owner draw feature?
-
I am using QListView to display a list of icons. For each icon item, I want to draw the icon by myself. Does QListView support a owner draw feature or can I override the draw event so that whenever an item is to be drawed, I can get notification and draw by myself instead of letting Qt to do that?
Thanks
-
You need to have your own delegate. When you want to have custom drawing you need to write you own delegate. Please look at writing CustomDelegate.
-
Hi,
To add to Dheerendra, you are looking for the QStyledItemDelegate class
-
OK. Thank you. It seems that I need to override QStyledItemDelegate::paint function, to draw the following thing for an item:
- An icon
- A text
- A checkbox
I have found the way of drawing checkbox. However, which event will be fired when the user clicking the checkbox? Since the checkbox is drawed by myself, how can an event be fired properly when user click it?