On 2007-11-19, Shriramana Sharma wrote:
> Hello.
>
> Nobody has replied to this mail of mine from last week. Please can
> anyone look into it and reply? Thanks.
>
> Please see the attached program. It's a simple todo program I wrote.
> "Kartavya" means "Something that needs to be done" in Sanskrit.
>
> I want to know why the spacing between the list items increases when
> items are added and how I can stop that from happening. The spacing
> between the list items must be constant whether there are items or not.

The reason that the spacing varies is that Qt's layout system is
content-sensitive---that is, it gives room in proportion to what is
actually needed.

However, you can override that:

height = QFontMetrics(window.font()).height()
for i in range ( 10 ) :
        checkboxes [ i ] . setEnabled ( False )
        checkboxes [ i ] . setContentsMargins ( 5, 5, 5, 5 )
        checkboxes[i].setMaximumHeight(height)
        checkboxes[i].setMinimumHeight(height)
        mainLayout . addWidget ( checkboxes [ i ] )

Note that this might fail, for example if the font is changed
dynamically. It also means that the minimum size of the widget becomes
fixed (10 * (height + (2 * margin))).

-- 
Mark Summerfield, Qtrac Ltd., www.qtrac.eu

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to