QScriptValue value = ...; // initialize the QScriptValue object QVariant variant = value.toVariant(); // convert to QVariant object
QScriptValue value = ...; // initialize the QScriptValue object if (value.isNumber()) { double number = value.toNumber(); // convert to double }In this example, the QScriptValue object is checked if it represents a number using the isNumber() function. If it does, it is converted to a double using the toNumber() function. This code belongs to the QScriptEngine package/library in Qt, which provides support for JavaScript-like scripting in C++ applications.