Here's essentially what I decided on. In general its a QListView or QListWidget (depending on if you want to write your own model, which is good if you have multiple views, ie. list view and icon view). I also use a QStyledItemDelegate to draw the items the way I want. I'm drawing the thumbnail and the text below it as well as a rounded focus rectangle instead of the default stippled line rect.
def __init__(self, parent=None):
self.
setIconSize(QtCore.
QSize(160,
90)) # or setGridSize self.
setResizeMode(QtGui.
QListView.
Adjust) # re-lays out the items on resize self.
setLayoutMode(QtGui.
QListView.
Batched) # does the layout with a timer for better performance self.setWrapping(True) # wraps the items to the next line so theres no horiz scrollbar
self.setDragEnabled(True) # in case you want drag and drop
self.setSpacing(1) # spacing between each item, buggy in Qt < 4.7 but works with small #'s
class QdIconView(QtGui.QListWidget):
def __init__(self, parent=None):
QtGui.QListWidget.__init__(self, parent)
self.setIconSize(QtCore.QSize(160, 90)) # or setGridSize
self.setViewMode(QtGui.QListView.IconMode)
self.setMovement(QtGui.QListView.Static)
self.setResizeMode(QtGui.QListView.Adjust) # re-lays out the items on resize
self.setLayoutMode(QtGui.QListView.Batched) # does the layout with a timer for better performance
self.setWrapping(True) # wraps the items to the next line so theres no horiz scrollbar
self.setDragEnabled(True) # in case you want drag and drop
self.setSpacing(1) # spacing between each item, buggy in Qt < 4.7 but works with small #'s
To copy to clipboard, switch view to plain text mode
Bookmarks