[PyKDE] PyQt4 Update

Phil Thompson phil at riverbankcomputing.co.uk
Sun Dec 4 20:25:06 GMT 2005


On Sunday 04 December 2005 7:46 pm, David Boddie wrote:
> On Sunday 04 December 15:01:20, Phil Thompson wrote:
> > On Saturday 03 December 2005 6:08 pm, Baz Walter wrote:
> > > The only very minor issue I came across was the following error when
> > > trying to pass Qt.AlignCenter to QLabel.setAlignment:
> > >
> > >       TypeError: argument 1 of QLabel.setAlignment() has an invalid
> > > type
> > >
> > > type(Qt.AlignCenter) gives <class 'PyQt4.QtCore.AlignmentFlag'> but the
> > > Qt docs suggest it should be of type Qt.Alignment. Anyway, it can be
> > > easily fixed by ORing together Qt.AlignVCenter and Qt.AlignHCenter.
> >
> > Thanks. The setAlignment() bug will be fixed in the next snapshot.
>
> I just assumed that the strict rules for flags and enum values were being
> applied for functions that take Qt.AlignmentFlag values. My workaround for
> cases like these was to use Qt.Alignment:
>
>   label.setAlignment(Qt.Alignment(Qt.AlignCenter))

Yes - I shouldn't have used the word "bug".

SIP doesn't support automatic type converters like C++ does, so I've been 
adding %ConvertToTypeCode in various places to make things a bit more 
convenient. This is one such place.

Phil




More information about the PyQt mailing list