[PyQt] Make main window expand when inner widget resized

Tony Arnold tony.arnold at manchester.ac.uk
Wed Jun 11 22:00:24 BST 2014


I have a QTableView widget inside a QMainWindow. The table view widget
has been initialised with:

        self.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)

so that the table view widget expands/shrinks as the contents of the
table expands and shrinks.

This works, however, the main window (which contains the table view
widget) stays the same size. I'd like it to expand and shrink and for it
to stay just big enough to contain the table view widget.

I've struggled for days to achieve this without success so far. I've
also googled this as much as I can. Does anyone have any suggestions?

Many thanks in advance.

Regards,
Tony.

-- 
Tony Arnold,                        Tel: +44 (0) 161 275 6093
Head of IT Security,                Fax: +44 (0) 705 344 3082
University of Manchester,           Mob: +44 (0) 773 330 0039
Manchester M13 9PL.                 Email: tony.arnold at manchester.ac.uk



More information about the PyQt mailing list