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

Phil Thompson phil at riverbankcomputing.co.uk
Thu Jul 6 18:44:39 BST 2006


On Wednesday 28 June 2006 12:08 am, Andreas Pakulat wrote:
> Hi,
>
> 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.

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.

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.

Phil




More information about the PyQt mailing list