I tried playing around with sizePolicy and minimumSize, but that did not accomplish anything useful.
Reimplementing sizeHint works better, e.g.:
QSize MyTreeWidget
::sizeHint() const {
int width=0;
for (int i=0; i<columnCount(); ++i)
width += 2 + columnWidth(i);
return QSize(width
+16-2,
100);
}
QSize MyTreeWidget::sizeHint() const
{
int width=0;
for (int i=0; i<columnCount(); ++i)
width += 2 + columnWidth(i);
return QSize(width +16-2, 100);
}
To copy to clipboard, switch view to plain text mode
That is, I basically add up the column-widths. Unfortunately I had to hardcode in "2" for the spacing between columns that is not included in the columnWidth(), and a "16" for the width of a scrollbar. Is there any way to ask Qt about these numbers?
Bookmarks