[PyQt] Problem updating QLabel font
mark at qtrac.eu
Mon Jan 7 15:41:04 GMT 2008
On 2008-01-07, Phil Thompson wrote:
> On Monday 07 January 2008, Arve Knudsen wrote:
> > Hello
> > I've run into what looks like a bug in PyQt. When changing the font of a
> > QLabel at runtime, it doesn't update its appearance unless I call its
> > update() method. I've verified that this problem doesn't occur when using
> > Qt directly from C++. Even after calling update(), something isn't right
> > however, as the containing QGridLayout isn't adjusted to account for the
> > label's changed dimensions.
> > The attached program showcases the problem. Uncomment line 20 to see the
> > layout problem.
> Change the first line of changeFont() to...
> f = QFont(self.__lab.font())
> ...so that it is closer to what C++ would do.
> SIP doesn't enforce "const". I've been mulling over this for a while. SIP
> could enforce "const" so that the call to setBold() would raise an
> exception. The disadvantage is that existing apps may break - but, then
> again, they are broken anyway.
> An alternative might be to automatically make a copy under the covers so
> that wrapped C++ instances are never const.
I think this second way would be easier for users and seems perfectly
Mark Summerfield, Qtrac Ltd., www.qtrac.eu
More information about the PyQt