[PyQt] Determine size of a button
David Boddie
david at boddie.org.uk
Sun Oct 16 15:08:25 BST 2011
On Fri, 14 Oct 2011 02:39:49 -0700 (PDT), Joe M wrote:
> The question is: is there a way in which I can tell how big the buttons
> will be without having to create them in the first place? Or any other
> hints?
You can make estimates based on the application's font size. However, there
are other factors you need to take into consideration, like the widget style.
In the end, it's probably just easier to create the button without showing
it and only put it in the layout if you need to use it.
The trick is to get the button to calculate its size without showing it
first. One thing I tried was to call its adjustSize() method. This seems
to work if it isn't in a layout, but you might want to see if it works for
your buttons.
David
More information about the PyQt
mailing list