PDA

View Full Version : QTreeWidget after calling setFont(), the column width suits no more to its content



cic
12th May 2014, 09:53
Hello all,

imagine there is a qtreewidget i used with 3 columns.
by default without setting the font using QTreeWidget::setFont() the content displayed after calling show()
suits to the contents.

While if i call the setFont() the first column always occupies the whole row, i need to scroll the horizontal bar to see
the rest of contents in 2nd and 3rd column.

is it a known bug?

PS: i think the way to setup the strech flag - QHeaderView::setResizeMode ( ResizeToContents) is not the way it is supposed to cause it limits the flexibility
in which the the user cannot adjust the column width by mouse.

After deeper debug, i found that when calling setFont() before settingup the header leads to a column size update...




case QEvent::FontChange:
case QEvent::StyleChange:
d->invalidateCachedSizeHint();
resizeSections();
emit geometriesChanged();
break;


while the header contains only one default column, the size is then set to the width of the whole row.