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

Phil Thompson phil at riverbankcomputing.com
Sun Dec 26 11:04:09 GMT 2010

On Sat, 25 Dec 2010 22:15:29 +1100, Xavion <xavion.0 at gmail.com> wrote:
> This used to work fine when my PyQt code was in Python v2 syntax.  I was
> using 'QVariant' when saving Boolean values and 'toBool()' when loading
> them.

In other words your application was explicitly saying how the value should
be interpreted.

> Now that I've upgraded my code to Python v3 syntax, 'QVariant' is gone
> I
> possibly shouldn't need to use 'bool()' either.  Given that Python wants
> receive 'False' when loading Boolean values, why is it saved to the
> configuration file as 'false'?

It's saved as a string if the backend can only save strings. It's saved as
"false", rather than "False", probably because it's the obvious value for a
C++ developer to use.

> If this can't be avoided, surely 'QSettings' can be improved to assume
> 'false' really means 'False', at least when importing from Linux
> configuration files.  What's your opinion about this idea?

A completely invalid assumption that can easily break existing


More information about the PyQt mailing list