Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_script_qjsengine.cpp File Reference

(0dc4fd240a2897c5c443a0ef6d84c416843e4938)

Go to the source code of this file.

Classes

class  MyObject
 [7] More...
 

Functions

args<< 1<< 2;QJSValue threeAgain=fun.call(args);QString fileName="helloworld.qs";QFile scriptFile(fileName);if(!scriptFile.open(QIODevice::ReadOnly)) QTextStream stream(&scriptFile);QString contents=stream.readAll();scriptFile.close();myEngine.evaluate(contents, fileName);myEngine.globalObject().setProperty("myNumber", 123);...QJSValue myNumberPlusOne=myEngine.evaluate("myNumber + 1");QJSValue result=myEngine.evaluate(...);if(result.isError()) qDebug()<< "Uncaught exception at line"<< result.property("lineNumber").toInt()<< ":"<< result.toString();QPushButton *button=new QPushButton;QJSValue scriptButton=myEngine.newQObject(button);myEngine.globalObject().setProperty("button", scriptButton);myEngine.evaluate("button.checkable = true");qDebug()<< scriptButton.property("checkable").toBool();scriptButton.property("show").call();QJSEngine engine;QObject *myQObject=new QObject();myQObject-> setProperty ("dynamicProperty", 3)
 
engine globalObject ().setProperty("myObject"
 
 qDebug ()<< engine.evaluate("myObject.dynamicProperty").toInt()
 [1]
 
engine evaluate ("var myObject = new MyObject()")
 [8]
 

Variables

QJSEngine myEngine
 [0]
 
QJSValue three = myEngine.evaluate("1 + 2")
 
QJSValue fun = myEngine.evaluate("(function(a, b) { return a + b; })")
 [0]
 
QJSValueList args = { object }
 
QJSValue myScriptQObject = engine.newQObject(myQObject)
 
QJSValue jsMetaObject = engine.newQMetaObject(&MyObject::staticMetaObject)
 [7]
 

Function Documentation

◆ evaluate()

engine evaluate ( )

[8]

[9]

◆ globalObject()

engine globalObject ( )

◆ qDebug()

qDebug ( )

[1]

[7]

[toString]

◆ setProperty()

args<< 1<< 2;QJSValue threeAgain=fun.call(args);QString fileName="helloworld.qs";QFile scriptFile(fileName);if(!scriptFile.open(QIODevice::ReadOnly)) QTextStream stream(&scriptFile);QString contents=stream.readAll();scriptFile.close();myEngine.evaluate(contents, fileName);myEngine.globalObject().setProperty("myNumber", 123);...QJSValue myNumberPlusOne=myEngine.evaluate("myNumber + 1");QJSValue result=myEngine.evaluate(...);if(result.isError()) qDebug()<< "Uncaught exception at line"<< result.property("lineNumber").toInt()<< ":"<< result.toString();QPushButton *button=new QPushButton;QJSValue scriptButton=myEngine.newQObject(button);myEngine.globalObject().setProperty("button", scriptButton);myEngine.evaluate("button.checkable = true");qDebug()<< scriptButton.property("checkable").toBool();scriptButton.property("show").call();QJSEngine engine;QObject *myQObject=new QObject();myQObject-> setProperty ( "dynamicProperty" ,
3  )

Variable Documentation

◆ args

QJSValueList args = { object }

Definition at line 12 of file src_script_qjsengine.cpp.

◆ fun

QJSValue fun = myEngine.evaluate("(function(a, b) { return a + b; })")

[0]

[1]

Definition at line 11 of file src_script_qjsengine.cpp.

◆ jsMetaObject

engine jsMetaObject = engine.newQMetaObject(&MyObject::staticMetaObject)

[7]

[8]

Definition at line 83 of file src_script_qjsengine.cpp.

◆ myEngine

QJSEngine myEngine

[0]

Definition at line 5 of file src_script_qjsengine.cpp.

◆ myScriptQObject

engine myScriptQObject = engine.newQObject(myQObject)

Definition at line 65 of file src_script_qjsengine.cpp.

◆ three

QJSValue three = myEngine.evaluate("1 + 2")

Definition at line 6 of file src_script_qjsengine.cpp.