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