readEntry and booleans

Thomas Braxton brax108 at
Wed Jan 4 01:24:42 GMT 2006

On Tuesday 03 January 2006 16:59, David Faure wrote:
> On Tuesday 03 January 2006 23:00, Cornelius Schumacher wrote:
> > compare
> >   readEntry( "key", QVariant( false ) ).toBool()
> > to
> >   readBoolEntry( "key", false )
> Since booleans convert so badly to QVariant, maybe we should keep
> readBoolEntry or add a readEntry( key, bool ) overload?

The problem wasn't with booleans, it was with zeroes. (i.e. 

As far as I can tell this member template fixes everything
template <typename T> T readEntry(key, const T&) const

This seems to work, I ran unsermake check on kdecore and it passes.
The only problem seems to be, all uses of QVariant::Bool/Int must be replaced 
& toInt()/toBool() must be replaced to compile. All in all I think the code 
looks a lot cleaner. You pass in a bool and you get out a bool, so code that 
looked like this

if (sc.readEntry(key, QVariant::Bool).toBool())

now looks like this

if (sc.readEntry(key, false))

-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff
Type: text/x-diff
Size: 3633 bytes
Desc: not available
URL: <>

More information about the kde-core-devel mailing list