[PyKDE] QObject.trUtf8 doesn't accept unicode strings.
Phil Thompson
phil at riverbankcomputing.co.uk
Wed Jan 3 15:30:56 GMT 2007
On Wednesday 03 January 2007 3:13 pm, Rick van Hattem wrote:
> Hello everyone,
>
> I was just writing some code today and after a while I came across some
> code that used unicode strings, normally not a problem but I noticed that
> tr and trUtf8 both don't accept unicode strings. Would it be possible to
> add this since it would be logical to convert a python unicode string to a
> QT escaped unicode string.
>
> Example code:
> from PyQt4 import QtCore
> object = QtCore.QObject()
>
> normal_string = str('test')
> unicode_string = unicode('test')
>
> ''' this works '''
> object.tr(normal_string)
> object.trUtf8(normal_string)
>
> ''' this doesn't '''
> object.tr(unicode_string)
> object.trUtf8(unicode_string)
>
> Naturally, the bottom two give a TypeError but I would expect it to do a
> cast to str() for tr or just accept the string for trUtf8.
tr() takes a char * and not a QString, so the PyQt version takes a string
object and not a unicode object.
Phil
More information about the PyQt
mailing list