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
det...@die-offenbachs.de
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to