QTableWidget how to scale the columns and keep the proportions?
Hi all! I have a question about QTableWidget. How can I keep a proportion of the columns when I refinable widget table(window application)?
For example I set for two columns following sizes:
Code:
self.tableAsset.horizontalHeader().resizeSection (0, 170)
self.tableAsset.horizontalHeader().resizeSection (1, 30)
Now I get that when you create the window size of the cells are correct, but when you scale extends only the latter, and it is necessary that they are uniformly scaled to keep its current proportions. I want to keep a prescribed proportion. Thanks in advance for your reply. And sorry for my bad English. :rolleyes:
Re: QTableWidget how to scale the columns and keep the proportions?
Please help, who knows how to solve this problem? :(
Re: QTableWidget how to scale the columns and keep the proportions?
You have to capture the resize event.
This was coded in PyQt
Code:
def resizeEvent(self, event):
# Dynamically resize rows and columns
rowHeight = ( self.size().height() - self.horizontalHeader().size().height())/6 - 1
colWidth = ( self.size().width() )/7 - 1
for x in xrange(0, 6): self.setRowHeight(x, rowHeight)
for x in xrange(0, 7): self.setColumnWidth(x, colWidth)