toInt() [Variant class]

Returns the value of the variant to an int (32-bit signed), converting the type if necessary. The original value is left unchanged.

Source Result
bool false → "false", true → "true"
numeric unchanged
String string number → 32-bit integer
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.

int toInt() const;
int toInt(bool& ok) const;

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