I'm writing a PyQt application and am having some trouble creating a custom list view. I'd like the list to contain arbitrary widgets (one custom widget in particular). How would I go about this?
It seems that the alternative would be to create a table or grid view wrapped in a scrollbar. However, I'd like to be able to take advantage of the model/view approach as well as the nesting (tree-view) support the built-ins handle.
To clarify, the custom widgets are interactive (contain buttons), so the solution requires more than painting a widget.
解决方案
I think you need to subclass QItemDelegate.
QItemDelegate can be used to provide
custom display features and editor
widgets for item views based on
QAbstractItemView subclasses. Using a
delegate for this purpose allows the
display and editing mechanisms to be