QScriptValue val = engine->newNumber(42); if (val.isNumber()) { qDebug() << "Value is a number"; } else { qDebug() << "Value is not a number"; }
QScriptValue obj = engine->evaluate("({prop: 10})"); QScriptValue prop = obj.property("prop"); if (prop.isNumber()) { qDebug() << "Property value is a number"; } else { qDebug() << "Property value is not a number"; }This example evaluates a JavaScript object containing a property called "prop". It then retrieves the value of "prop" using the property() function and checks if it is a number using the isNumber() function. Package library: QtScript module in Qt for C++.