toBool() [Variant class]

Returns value of the variant to an bool (boolean, true or false), converting the type if necessary. The original value is left unchanged.

Source Result
bool unchanged
numeric zero (0) → false, non-zero → true
String falsefalse, 'true' → "true"
other conversion fails

There are two overloads, one that takes an ok parameter passed by reference, which is filled in as true if the data is already this type or can be converted.

bool toBool() const;
bool toBool(bool& ok) const;

See value, as, and to for when to use the toXXX() vs. other accessors.