Pyqt5 Change Table Widget Column Width

pyqt5 change table widget column width
header = self.table.horizontalHeader()
header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
header.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
#the first column will stretch to fill the window and the others will resize
#to the contents. If you want them to be equally sized change all resize modes
#to QtWidgets.QHeaderView.Stretch

Leave a Comment