PDA

View Full Version : QTableWidget how to scale the columns and keep the proportions?



irendeir
22nd November 2012, 14:41
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:


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:

irendeir
23rd November 2012, 07:39
Please help, who knows how to solve this problem? :(

prof.ebral
23rd November 2012, 14:00
You have to capture the resize event.

This was coded in PyQt


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)