I generally do this by extending the table view and modifying the resizeEvent method;
# Python code ...
def __init__(self, model, parent = None):
super(MyTable, self).__init__(parent)
rowHeight = self.fontMetrics().height()
self.verticalHeader().setDefaultSectionSize(rowHeight)
self.setModel(model)
def resizeEvent(self, event):
width = event.size().width()
self.setColumnWidth(1, width * 0.25) # 25% Width Column
self.setColumnWidth(2, width * 0.75) # 75% Width Column
# Python code ...
class MyTable(QTableView):
def __init__(self, model, parent = None):
super(MyTable, self).__init__(parent)
rowHeight = self.fontMetrics().height()
self.verticalHeader().setDefaultSectionSize(rowHeight)
self.setModel(model)
def resizeEvent(self, event):
width = event.size().width()
self.setColumnWidth(1, width * 0.25) # 25% Width Column
self.setColumnWidth(2, width * 0.75) # 75% Width Column
To copy to clipboard, switch view to plain text mode
Bookmarks