PDA

View Full Version : QTableWidget and resizeRowToContent



spacer2004
27th August 2009, 15:41
I want to resize the rows of my table to the content. Into my table i have a column with a QTextEdit-widget. Into the contructor of my tablewidget class i set the resizemode of the vertica lheader to QTableWidget::verticalHeader()->resizeMode(QHeaderView::ResizeToContents).
Into my delegate class i overwrite the method sizeHint. Into this method i calculate the size for the column of my QTextEdit-widget with
QTextDocument doc;
doc.setHtml(index.data().toString());
return doc.size().toSize();
The problem is, when i insert a small word into the widget the sizeHint method return the row height 22, but when the size of the rect in the paint methode of the delegate has the row height 392. The row is paint too high.
So, what's going wrong?