[PyQt] Unicode errors with PyQt5?

Phil Thompson phil at riverbankcomputing.com
Thu Sep 6 08:57:16 BST 2018


On 6 Sep 2018, at 6:26 am, Chris Pezley <chris at pezley.net> wrote:
> 
> Hi,
> 
> try setting the sip api to use version 2 at the beginning of your program:
> 
> import sip
> sip.setapi('QDate', 2)
> sip.setapi('QDateTime', 2)
> sip.setapi('QString', 2)
> sip.setapi('QTextStream', 2)
> sip.setapi('QTime', 2)
> sip.setapi('QUrl', 2)
> sip.setapi('QVariant', 2)
> This will make Qt give you unicode strings and get rid of QVariants in lieu of native python types. Unfortunately the documentation for this is a bit lacking (http://pyqt.sourceforge.net/Docs/sip4/python_api.html?highlight=setapi), so it is hard to find the api options.

Python v3 uses the v2 APIs by default.

Phil


More information about the PyQt mailing list