Pyqt: How to increase the width of a column in a table?

In fact, the header contains all the necessary information. Is there a simple function like tableview.resizeColumnsToContents () that allows you to maximize the width of the columns within the size of the widget? My columns are narrow, so the table looks very compact.

+5
source share
2 answers

If you want the columns to expand evenly, you can also set the resize mode

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

In pyqt5 is setResizeModeno longer available. Instead, use setSectionResizeModeand QHeaderViewin the module QtWidgets.

+8
source

All Articles