I was using PyQt4 and this code works great.
self.table.horizontalHeader().setResizeMode(1, QHeaderView.Stretch)
It\'s stretching a column
In PyQt5 should be:
header = self.table.horizontalHeader()
header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
header.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
Use QHeaderView.setSectionResizeMode instead of QHeaderView.setResizeMode:
Use setSectionResizeMode instead.
(Quote from documentation for QHeaderView.setResizeMode)