PDA

View Full Version : setting row height in QTreeView?



gfunk
27th July 2006, 00:07
I see that you can resize the header() to change column widths in a QTreeView, but how can you set the row heights?

In particular, I am trying to call setIndexWidget() to add some pushbuttons into my Treeview, but when I do that, the rows suddenly become narrower, and I can barely read the text on my button. I'm hoping there is a way to do it without having to subclass an existing class?

I tried setGeometry() on the QPushButton and it didn't change size. I tried setMinimumSize() and it drew the button larger but the row height stayed the same, thus causing some drawing overlap.

wysota
27th July 2006, 13:57
set SizeHintRole roles for your model items. The treeview takes the row height from the model. Alternatively, if you don't want to modify the model, reimplement QItemDelegate::sizeHint in the delegate.

gfunk
28th July 2006, 01:05
Using SizeHintRole roles works perfectly!

I gave the delegate thing a try, but it didn't seem to work, wasn't even getting any breakpoints hit inside. Aren't delegates only used by the app when you try to edit a cell (such as by trying to double-click on it)

wysota
28th July 2006, 01:47
Aren't delegates only used by the app when you try to edit a cell (such as by trying to double-click on it)

No, they also render items to the view and return size hints for them.