[PyQt] strange extra spacing between checkboxes
mark at qtrac.eu
Tue Nov 20 08:01:42 GMT 2007
On 2007-11-20, Shriramana Sharma wrote:
> Mark Summerfield wrote:
> > height = QFontMetrics(window.font()).height()
> > checkboxes[i].setMaximumHeight(height)
> > checkboxes[i].setMinimumHeight(height)
> Thanks. Adding these lines corrected the problem.
> > Note that this might fail, for example if the font is changed
> > dynamically.
> Do you mean that if the font size is changed (or the font changes and
> the font carries a different size hint) then the virtually-hardcoded
> size of the checkboxes might mean that the text is cropped? If yes, then
> it should be trivial to add lines to update the min and max heights if
> the font is changed, no?
All I meant was that any other part of your program could in theory
change the font size, but the code above hard-codes values just once.
> > It also means that the minimum size of the widget becomes
> > fixed (10 * (height + (2 * margin))).
> That's not a problem, is it? Or could it be?
That depends on what you want:-) The only problem is that if you allowed
a *lot* of checkboxes and your user had a small screen, maybe the window
would be too tall to fit.
There are other possibilities; for example, you could start out with
_no_ checkboxes and add them dynamically as needed; or you could use a
QListView and add checkable QListViewItems; and no doubt there are other
Mark Summerfield, Qtrac Ltd., www.qtrac.eu
More information about the PyQt