Unsolved How to automatically resize Qtable widget according to the item.
-
I want to resize my table widget according to my item which I am giving through hardcode.
I used bellow code but is not resizingself.statTable.setSizeAdjustPolicy( QtWidgets.QAbstractScrollArea.AdjustToContents)
-
Hi,
Please show the code you use to initialize that widget and its content.
-
This post is deleted! -
self.tblDropdown = self.dialogDropdown.findChild(QTableWidget, "tbl_dropdown") dropdownList = args[2]["list"] for i in range(len(dropdownList)): self.tblDropdown.insertRow(i) self.tblDropdown.setItem(i, 0, QTableWidgetItem(dropdownList[i]))
-
Why do you need findChild in the first place ?
You need to call resize manually once you added all the items you want.
-
I did findchild for table so, that I can add my item in table.
for resizing i am adding "self.statTable.setSizeAdjustPolicy(
QtWidgets.QAbstractScrollArea.AdjustToContents)" is this correct to resize the table bcz automatically table is not resizing. -
Using findChild like that is not a good sign. It looks like you do not really know where that QTableWidget is located or that you are trying to fill it from somewhere not appropriate.
No it's not, QTableWidget does not contain a widget. It draws its content hence my suggestion about calling resize once you have filled it.