[PyQt] A possible bug in PyQt when loading Boolean values via QSettings

Xavion xavion.0 at gmail.com
Sat Dec 25 02:36:37 GMT 2010

I think I've encountered a bug in PyQt v4.8.1 when loading Boolean types via
QSettings.  I'm also using SIP v4.11.2 and Python v3.1.3.

Here's the code I'm using to save the setting:

if Main.uiSettings.cbPreferSUdo.checkState() == QtCore.Qt.Unchecked :
>     User.System.bPreferSUdo = False
> else :
>     User.System.bPreferSUdo = True
> Settings.beginGroup( "System" )
> Settings.setValue( "Prefer SUdo", User.System.bPreferSUdo )
> Settings.endGroup()

Here's the code I'm using to load the setting:

Settings.beginGroup( "System" )
> oItems = Settings.value( "Prefer SUdo" )
> if oItems :
>     User.System.bPreferSUdo = oItems
> Settings.endGroup()

I think there's a bug in PyQt, because I'm getting inconsistent results.
For this example, I've ensured that the check-box is set to 'False' before
saving the setting.

If I save the setting and load it again (while the application is still
running), the correct 'False' value is returned (from cache).  If I save the
setting, quit and restart the application, then load the setting, an
incorrect 'false' value is returned (from the configuration file).  Using a
'bool()' cast makes no difference.

In the second case, the lowercase 'f' in 'false' actually means that the
check-box becomes set to 'True'.  This means that I'm effectively getting
black when I want white.  Can someone confirm whether this is a bug in PyQt
and how long it'll take to fix?  I was planning to release the next version
of my application today.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101225/31e726f6/attachment-0001.html>

More information about the PyQt mailing list