"complete control" owner drawing of QListWidget rows
-
I need a view that's something like Skype's contact view. List of names, with an image at their side, and some buttons that become visible as you select a row. Using QListWidgetItem does answer some of these requirements but is severely limited, by icon width and others.
One other thing that's less of a priority -- QListWidget scrolls in rigid steps. The scroll is not smooth and you can never see "half a row" like you can in Skype. It's like QListWidget scrolls up and down in row-height steps, while Skype scrolls in single pixels. Much smoother and pleasing from a UX standpoint. I know Skype is QT. Are they using a different control for this?
How do I achieve complete control over the drawing of a row in QListWidget?
-
Not so sure about a model. I have a QListWidget to which i "add" instances of QListWidgetItem. Are you saying I can instantiate an external "Data model", populate it with my data, and then have the QListWidget use that as the source to populate rows instead of me "adding" it manually there?
-
That makes life sometimes a bit easier, especially when you do more complex things.
You use a QListView as widget and create a custom model derived from QAbstractListModel, that's not too hard, especially if it's read only.
Then you can use a QSFPM (QSortFilterProxyModel) which you use in the view to do sorting. If you use QSFPM you have full access to the sorting criteria.
Via a custom delegate (derived from QStyledItemDelegate) you can do custom drawing, change the size hint for rows etc.