[Interest] QSettings: is a group present? Crash with qWarning.

Sensei senseiwa at gmail.com
Fri Aug 24 11:00:33 CEST 2012


On 8/24/12 8:59am, Thiago Macieira wrote:
>> So there's a "bug" in the docs... am I right?
>
> No. It's not a bug if it's intentional.
>
> QBool is a hidden class that is actually a bool. In most cases, you don't
> realise it's there because it casts automatically to bool. The two cases that
> it won't do are in ... passing and in template matching.
>
> Qt 4 has been using QBool for 7 years and you're the first person who has come
> to this error, so I don't think it's a real issue (and you probably ignored a
> compiler warning).

Yep, as a matter of fact I ignored several compiler warnings. They all 
refer to QVector:

/Applications/Development/qt/Desktop/Qt/4.8.0/gcc/lib/QtCore.framework/Headers/qvector.h:323:98: 
Implicit conversion loses integer precision: 'long' to 'int'

Apart from the obvious #warning about the new operating system being 
unsupported.

> QBool exists to mark a function that returns a boolean in Qt 4, but returned
> an int in Qt 3. It exists to make sure you're not treating the return value
> like it was done in Qt 3. E.g.:
>
> 	QString foo("hello hello");
> 	if (foo.contains("hello")>  1) { ... }
>
> The above was valid in Qt 3 but in Qt 4 it should error out. If the function
> returned boolean, it would compile but it would be always false.

Thanks for your clarification, I am glad to be the first one to smash 
his nose on this! :)

Cheers!






More information about the Interest mailing list