PDA

View Full Version : QTableView row height via delegate and setRootIndex



pmaktieh.sirhc
16th January 2007, 15:33
Hi,

I have a QTableView with a delegate, this sets the row height of the table view, via override sizeHint:


QSize MyClass::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QSize s = QItemDelegate::sizeHint(option, index);

if ( s.isValid() )
s.setHeight(20);

return s;
}

This works 100%. But if I set a new root index for the tableview:


void QAbstractItemView::setRootIndex ( const QModelIndex & index )

the row height is set to default height. The delegate is ignored! I need a fixed row height, also after a new root index!


Does anyone know, what the problem is? How can I fix this?

Thanks!
Chris

wysota
18th January 2007, 10:18
Could you post a minimal compilable example reproducing the problem?

pmaktieh.sirhc
18th January 2007, 19:06
I've found my mistake, I must call


void QTableView::resizeRowsToContents()

after the new index has set!

...nevertheless thanks for your help!

Chris