Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyqt: How to maximize the column width in a tableview?

Tags:

pyqt

Actually the title contains all information needed. Is there an easy function like tableview.resizeColumnsToContents() that allows the maximization of all column widths within the widget size? My columns are narrow so the table looks very compact.

like image 694
gruenkohl Avatar asked Jun 16 '11 13:06

gruenkohl


1 Answers

If you want the columns to expand uniformly, you could also set the resize mode

tableview.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)

In pyqt5 setResizeMode is no longer available. Instead, use setSectionResizeMode and QHeaderView in the QtWidgets module.

like image 150
Stephen Terry Avatar answered Sep 27 '22 19:09

Stephen Terry