Jason had some of the solution. The height of the treeview's rows needs to be resized as well:
class MyDelegate(QItemDelegate):
def __init__(self):
QItemDelegate.__init__(self)
def sizeHint(self, option, index):
return QSize(32,32)
Then, elsewhere:
delegate = MyDelegate()
tree = QTreeWidget()
tree.setItemDelegate(delegate)
Not ideal as it resizes every row.
[edit] If you want to vary the size of the rows ensure the QTreeWidget/View.uniformRowHeights == False
Then mess around using the index. For me I wanted the 2nd row to bigger than the rest. I'm sure there's a better way but my sizeHint became:
def sizeHint(self,option,index):
parent = index.parent()
if parent.isValid() and not parent.parent().isValid():
return QSize(32,32)
return QSize(24,24)
However, there's another issue with this. Icons are not resizeable. Ah! That has to be done with
QTreeWidget.setIconSize(QSize(width,height))