Questions tagged [qjsengine]

Provides an environment for evaluating JavaScript code

The QJSEngine class provides an environment for evaluating JavaScript code

40 questions
7
votes
1 answer

QtScript vs QJSEngine when to use one or another?

I have to run a series of javascript 'scripts' in a C++ application. Most of them are repetitive actions. Example of code here. I know Qt since version 5 contains 2 javascript engines: QtScript and QJSEngine. My question is in which situations…
RandomGuy
  • 648
  • 6
  • 21
6
votes
1 answer

Can I change the document method of javascript: hasFocus() to return 'true' all the time?

I am trying to fool this specific code:

Click anywhere in the document (the right frame) to get focus. If you click outside the document, it will lose focus.

Sion C
  • 439
  • 2
  • 14
5
votes
1 answer

QJSEngine deletes my QObject, how to change ownership after QJSEngine::newQObject?

Trying to perform small script with subclassed QObject as parameter. QJSEngine jsEngine; QJSValue arg = jsEngine.newQObject(child); // Child it's subclassed QObject QJSValue function = jsEngine.evaluate(m_childRestriction); QJSValue result =…
Serhiy
  • 1,332
  • 1
  • 16
  • 24
4
votes
2 answers

Qt QJSEngine import js files

Is it possible to import javascript files in a QJSEngine (QT 5.6)? Example 1: Text in plainTextEdit: .import "./jsimport.js" as Test var x = Test.y; console.log(x); c++: void MainWindow::on_pushButton_clicked() { QJSEngine engine; …
Mike
  • 53
  • 1
  • 7
4
votes
4 answers

How to build an API with QJSEngine?

I am starting with Qt and one of my projects is using QJSEngine to evaluate javascript and I want to provide an entire API to the script, with classes and global functions. Right now my program provides only the ECMAScript default stuff (eval,…
Guerreiro
  • 143
  • 1
  • 11
3
votes
1 answer

QJSEngine - exposing classes and throwing errors

I am trying to create a standard JS library that is mostly shaped like Qbs (which uses deprecated QScriptEngine) with QJSEngine, so people who make Qt software can add things like file-operations to their plugin JS environment. You can see the repo…
konsumer
  • 3,411
  • 1
  • 30
  • 31
2
votes
0 answers

Does using QJSEngine have security implications for my application?

I am using QJSEngine to let the user script custom data transforms in my application. I understand QJSEngine is not sandboxed and runs at the same privelege level as my application. Does this have security implications I need to worry about? I am…
Andy Brice
  • 2,297
  • 1
  • 21
  • 28
2
votes
1 answer

How to expose enum not owned by QObject to QJSEngine?

I am writing scripting wrappers for my SW so I can control my SW via scripts. The purpose of the wrapper classes is to separate the scripting interface from the actual class because I might not want to expose all of the signals and slots of the…
Dago
  • 1,349
  • 1
  • 11
  • 19
2
votes
0 answers

With deprecation of QScriptEngine, how do we port the QScriptClass-related code?

QScriptEngine is deprecated and porting related code involves using either QJSEngine or the derived class QQmlEngine. These classes work with QObject-derived classes only. In the QScriptEngine world, non QObject-derived classes could be made…
lopippo
  • 43
  • 5
2
votes
1 answer

Multiple instances of QJSEngine within a single app?

Is it normal for a single C++/Qt5 app to have multiple independent instances of JavaScript engine? In my app, I have several QObject-inherited objects which act as independent data-processing units. In each of them, I want to be able to launch JS…
Maximko
  • 627
  • 8
  • 20
2
votes
0 answers

How to create a QJSValue object of type Error - throwing errors from QJSEngine

In Qt, does anyone know how to create a QJSValue of type Error? Context: I use QJSEngine::evaluate() to execute JavaScript code written by a user in GUI created with QT. That JavaScript code calls a C++ function. According to the documentation the…
pablo_worker
  • 1,042
  • 9
  • 26
2
votes
0 answers

Migration from QScriptEngine to QJSEngine

I'm migrating QScriptEngine code over to QJSEngine. Now, I have: class pars { public: static QScriptValue PrintMainLog(QScriptContext* c, QScriptEngine* e); }; QScriptValue pars::PrintMainLog(QScriptContext* c, QScriptEngine* e) { //some…
Aksandr
  • 21
  • 2
2
votes
0 answers

QJSEngine checkForSyntax function

In LiScriptEngine we have the following function:- QScriptSyntaxCheckResult QScriptEngine::checkSyntax(const QString & program) which is more useful to identify the type of error occured when engine executes a program.Currently i am migrating…
anbu selvan
  • 725
  • 3
  • 13
  • 41
2
votes
1 answer

Result of QJSEngine evaluation doesn't contain a function

I'm migrating QScriptEngine code over to QJSEngine, and have come across a problem where I can't call functions after evaluating scripts: #include #include int main(int argc, char *argv[]) { QCoreApplication a(argc,…
Mitch
  • 23,716
  • 9
  • 83
  • 122
2
votes
0 answers

QJSEngine vs QtScript and QList

Since Qt 5.5 is actual, QtScript is deprecated. The replacement is Qt QML with QJSEngine. Now, I will rewrite my project to the new engine. I have some Classes like: class Node : public QObject { Q_OBJECT Q_PROPERTY(QList childs READ…
Rico
  • 33
  • 1
  • 1
  • 8
1
2 3