Reputation: 539
I have seen this and this and I have also tried:
self.myButton = QtGui.QPushButton("Click")
a = self.myButton.size()
print a
things like these, but I'm still unable to get a single button's size info. When I print a
, it returns the size of the parent window, I think. Basically it returns a size that is clearly not the button's size because the return value is too big to be that button's size. Yes I feel like this is a very newbie question but I am just stuck with this. I'd appreciate your help with this, thank you in advance.
Upvotes: 0
Views: 1428
Reputation: 19112
You have to parent the widget or put it in a layout for it to be able to calculate its size. Without a specified parent, it is kind of lost...
...or rather it thinks it is going to be a window by itself and uses the minimum size for a window for the platform you are on.
Hope that helps.
Upvotes: 1