How to adjust size of treewidget??

  • Hi,

    i have a problem with my treewidget. I want it to adjust the size to fit the content. But the window is always too long (y-direction) and too thin (x-direction) if i manual resize it without calling adjustsize it works fine but using adjust size destroys it again.

    How it looks with resize:

    How it should look like:

    It should not resize the text size and display the whole name.

    Any ideas why this happens?? furthermore i want to resize it with the mouse. But adding a QSizeGrip to the widget displays the sizegrip at the upper right corner and adding it to the tree it's displayed at the same position and both ways only the widget is resized and not the tree. I already tried to make the widget to resize the child in the resizeEvent function, but nothing works. Maybe you have a solution for that, too


  • @QT-static-prgm I think if you want to force it to be the size to show the entire child item you will need to use a QFontMetric to figure out the actual size of the item then resize your tree to fit the child item.

    You can also try setting the sizeHint and then using adjustSize.

    If there is space on the screen but it isn't filling the space properly then that is a layout issue. I can't tell from the code since I don't see where you use it and therefore can't see the layout code.

Log in to reply