[PyQt] QString and unicode problems

Hans-Peter Jansen hpj at urpla.net
Tue Oct 18 13:40:35 BST 2011


Am Tuesday 18 October 2011 11:07:24 schrieb Andrei Kopats:
> Hi
>
> I am developing PyQt app now, and I very often have crashes,
> connected with QString usage. There are 2 reasons for exceptions:
> - QString contains unicode characters

never had problems with that, as long as you provide proper unicode 
objects, or convert back to unicode objects.

> - python method called for Qt string. Sometimes called somewhere deep
> in 3rdparty code, such as os.path.blabla(QString))

return -ERRORBETWEENCHAIRANDKEYBOARD

> See code examples at the end
>
> It is easy to forget about QString conversions, because there are a
> few different cases:
> - if you define string in Python code - it is Python string
> - if you take it from PyQt4 - it is QString
> - If you passed Python string through signal-slot - it becomes
> QString.

- use V2 sip API and eliminate QStrings completely

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/incompatible_apis.html

Please check, how things work for you using this, and call back.

Pete


More information about the PyQt mailing list