SizeHint is not working as I expect it to
-
So I have a QListWidget fileld with QlistWidgetItems that hold a custom widget I made. That only holdes some lables and an image.
When I press it I add some more labels at the bottom. This is made by overriding the mousePressEvent in my custom widget (when it get pressed again it removes the extra labels) . And the QListWidget click item singal calls function doing this:
timeCardWidget = self.cardListWidget.itemWidget(item) temp = timeCardWidget.sizeHint() item.setSizeHint(temp)
Creating this result:
Pressing the item again and it goes back to original size. This works for the most part but sometimes it wont adjust the size at all. Seams very random.
But I want to add the functionality of when I press one item i want to close the other items.
So i add this code in the QListWidget clicked singal function:for i in range(self.cardListWidget.count()): t = self.cardListWidget.item(i) timeWidget = self.cardListWidget.itemWidget(t) if t != item: timeWidget.closeItem() t.setSizeHint(timeWidget.sizeHint()) timeCardWidget = self.cardListWidget.itemWidget(item) temp = timeCardWidget.sizeHint() item.setSizeHint(temp)
Making it call the "close" function from the custom widget. Which dose the same thing when an item is pressed and minimizes by removing the extra labels at the bottom.
But with this code I get weird behaviour where it will not minimize them all. All without the item that was pressed before the current item is pressed. Showed in the link
https://gyazo.com/2c090e26b58cdfc32df350588e4233a8
Im so confused and cant figure out how to fix it. Any help appreciated!