[PyQt] QTreeWidget and fixed column widths on window resize

Tyler Distad tyler.distad at gmail.com
Fri Aug 1 00:39:08 BST 2008

> Not really. From the docs:
> ----------------
> stretchLastSection : bool
> This property holds whether the last visible section in the header takes up
> all the available space.
> The default value is false.
> Note: The horizontal headers provided by QTreeView are configured with this
> property set to true, ensuring that the view does not waste any of the space
> assigned to it for its header.
> Also note: If the value is set to true, this property will override the resize
> mode set on the last section in the header.
> ----------------
> You need to unset stretchLastSection first, then set it to a fixed size.

Bingo. Thank you. That's exactly what I  needed.
Final result, for anyone's reference:

self.ui.myTreeWidget.header().setResizeMode(0, QHeaderView.Stretch)

More information about the PyQt mailing list