PDA

View Full Version : Changing row height



supergillis
24th November 2008, 10:45
Hi,
I am trying to change the height of my rows with a custom item delegate.
I got this, but it doesn't work...


QSize ListItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index)
{
QSize size = QItemDelegate::sizeHint(option, index);
size.setHeight(size.height()+10);
return size;
}

What am I doing wrong?

Thanks in advance,
Gillis

caduel
24th November 2008, 13:49
* just to be on the safe side: have you (not) set uniformRowHeights() on the view?
* maybe your model returns some different value in its SizeHintRole?

supergillis
24th November 2008, 14:25
I did have uniformRowHeights(true) on the view, but it make any difference after removing. My model didn't return SizeHintRole so that wasn't the problem either. But after adding the SizeHintRole in the model it worked.

This is what I have now, and it works perfect :)

...
else if(role == Qt::SizeHintRole)
{
return QSize(0, 20);
}
...

Thanks!