QScriptValue myFunc = engine->evaluate("function myFunction(x, y) { return x + y; }"); if (myFunc.isFunction()) { qDebug() << "myFunc is a function"; }
QScriptValue value = engine->evaluate("myVariable"); if (value.isFunction()) { QScriptValue result = value.call(); qDebug() << "result of myVariable() function:" << result.toString(); }This example demonstrates how the isFunction() method can be used to determine if a QScriptValue represents a function stored in a variable. If it is a function, it can be called using the call() method, as shown here. In both examples, the package library is the Qt framework's scripting module, as QScriptValue is part of that library.