[PyQt] QSettings boolean converted to unicode with SIP API v2
detlev
detlev at die-offenbachs.de
Thu Apr 15 18:18:38 BST 2010
On Donnerstag, 15. April 2010, Jugdish 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))
>
You have to do a manual conversion. The same is true for other types as well
(e.g. int). Please see the eric5 source code for examples of handling
QSettings.
Detlev
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the PyQt
mailing list