[PyKDE] QTranslator.load(str data) doesn't work

Andreas Pakulat apaku at gmx.de
Thu Jul 6 18:51:31 BST 2006


On 06.07.06 18:44:39, Phil Thompson wrote:
> On Wednesday 28 June 2006 12:08 am, Andreas Pakulat wrote:
> > I just tried to load the data from a .qm file into a QTranslator using
> > it's load(self, str data) method. The function returned fales. Using the
> > same file load(const QString filename ...) works perfectly.
> 
> The bug is down to the similarity of the two Python signatures. The data you 
> are loading is being automatically converted to a QString and being used as a 
> filename.

I guessed so.

> There are a number of ways to fix this. The correct fix is to switch the order 
> of the two methods in the .sip file, but that would mean that any filename 
> must be specified explicitly as a QString and not a Python string. In other 
> words...
> 
>     load("i18n_ar.qm")
> 
> ...would fail because "i18n_ar.qm" would be interpreted as the data and not 
> the name of the file containing the data. I think that would come as a 
> surprise, and this would be the most common use case.

I fully agree with you on that.

> So I've decided to do the same as I did in PyQt3 and explicitly require the 
> data length argument to specified, rather than it be calculated 
> automatically. Originally I think this was a mistake on my part (as it is 
> inconsistent with similar uses elsewhere in the API) but it does have the 
> advantage of disambiguating the Python signatures.

That's fine with me. Thanks for looking into this.

Andreas

-- 
You work very hard.  Don't try to think as well.




More information about the PyQt mailing list