Warning, /frameworks/kjsembed/README.md is written in an unsupported language. File is not indexed.
0001 # KJSEmbed 0002 0003 Binding Javascript object to QObjects 0004 0005 ## Introduction 0006 0007 KSJEmbed provides a method of binding JavaScript objects to QObjects, 0008 so you can script your applications. 0009 0010 0011 ## Usage 0012 0013 If you are using CMake, you need to have 0014 0015 find_package(KF5JsEmbed NO_MODULE) 0016 0017 (or similar) in your CMakeLists.txt file, and you need to link to KF5::JsEmbed. 0018 0019 The KJSEmbed::Engine class provides the main interface for running embedded 0020 Javascript. 0021 0022 KJSEmbed::Engine *engine = new KJSEmbed::Engine(); 0023 KJS::Interpreter *interpreter = engine->interpreter(); 0024 interpreter->setShouldPrintExceptions(true); 0025 KJS::ExecState *exec = interpreter->globalExec(); 0026 KJS::UString code("print(\"Hello World\")"); 0027 KJSEmbed::Engine::ExitStatus exitstatus = engine->execute(code); 0028 KJS::Completion completion = engine->completion(); 0029 if (exitstatus != KJSEmbed::Engine::Success) { 0030 KJS::JSValue* value = completion.value(); 0031 qDebug() << value->toString(exec).qstring(); 0032 } 0033 0034