Issue
Hi, I have created MainWindow as shown above. I want to expand the first widget (plots) as much as possible so that the other two widgets fit content (or actually, I want to remove white empty space below tables). I don't know how to do that.
Currently, both table vertical header size policy is set to FitToContent.
Also, it needs to be dynamic so if I add a new row to the table, a new row should be visible (table will be larger).
I hope I'm clear enough, and also hope there is no need for runnable code.
Solution
Ok, I figure it out.
Reimplementing the resizeEvent will do the trick.
def resizeEvent(self, event):
super(Table, self).resizeEvent(event)
height = self.horizontalHeader().height()
for row in range(self.model().rowCount()):
height += self.rowHeight(row)
if self.horizontalScrollBar().isVisible():
height += self.horizontalScrollBar().height()
self.setMaximumHeight(height + 2)
I'm changing the height of QTableView. I'm including height of horizontal header + height of all rows + height of horizontalScrollBar if it is visible.
Answered By - Brat Karamazov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.