[PyQt] QSettings boolean converted to unicode with SIP API v2

Phil Thompson phil at riverbankcomputing.com
Thu Apr 15 12:18:20 BST 2010


On Thu, 15 Apr 2010 12:09:44 +0100, Jugdish <jugdizh at gmail.com> wrote:
> When using v2 of the API for QString and QVariant, if you write a boolean
> value to a QSettings file and then read the value back in from a
different
> session, it comes back as a unicode string. Example:
> 
> ##################
> # write out the qsettings file
> ##################
> import sip
> sip.setapi('QVariant', 2)
> sip.setapi('QString', 2)
> 
> from PyQt4 import QtCore
> 
> settings = QtCore.QSettings()
> settings.setValue("foo", False)
> 
> ##################
> # separate session, read in the qsettings file
> ##################
> import sip
> sip.setapi('QVariant', 2)
> sip.setapi('QString', 2)
> 
> from PyQt4 import QtCore
> 
> settings = QtCore.QSettings()
> val = settings.value("foo")
> print "val = %s (%s)" % (val, type(val))

http://www.riverbankcomputing.com/pipermail/pyqt/2009-December/025476.html

Phil


More information about the PyQt mailing list