Questions tagged [qtscript]

QtScript is an ECMA262-compatible implementation of JavaScript. It is the successor of QSA (Qt Script For Applications), but is being phased out in recent Qt versions in favour of Google's V8 engine.

Documentation can be found here (Qt4) and here (Qt5).

116 questions
1
vote
1 answer

How to create an 'array-like' property that JS code can modify in place?

I have a QObject-derived class that looks like this: class TestObject : public QObject { Q_OBJECT Q_PROPERTY(QStringList contents READ contents WRITE setContents) public: QStringList contents() { return m_contents; } void…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
1
vote
1 answer

Problem in variable affectation in QtScript

I'm trying to get the result of a script simple operation on the C++ side. I create a QScriptValue (myvar) and call engine.globalObject().setProperty("result", myvar); Then I evaluate "result = anothervar + 7;" The evaluate method return value is OK…
JFM
  • 11
  • 2
1
vote
2 answers

QtScript Introspection/Reflection?

Does QtScript support introspection/reflection (i.e. like python's dir() for example) that would enble me to 'map out' an api from the inside by exploring the object model at runtime?
PixelRouter
  • 103
  • 6
1
vote
1 answer

How to create an environment variable in Qt Installer framework regardless of OS

How can I add a new Environment Variable to the Qt installer. I know that it should go in the .qs script something like the following: var path = installer.environmentVariable("PATH") + ";" +…
bardao
  • 914
  • 12
  • 23
1
vote
1 answer

Issues using QScriptEngine: Must construct a Q(Core)Application before a QScriptEngine

I have a Qt Gui application using mainwindow widget. The window class looks like that: class MainWindow : public QMainWindow { Q_OBJECT ... public: MainWindow(QWidget *parent = 0); ~MainWindow(); //some more code private: …
GFd
  • 21
  • 5
1
vote
0 answers

How to clone function in Qt script?

I want to send Qt script data into another thread. To do that, I must copy the data, since the QScriptValue objects refer to javascript objects, rather than containing them. How can I clone a function? This isn't very good, cloning entry into…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
1
vote
2 answers

How to enable QtScript in your project when using MS Visual Studio compiler?

With QMake, the setup for QtScript is as simple as adding this to your .pro file: QT += script But we'e using MS Visual Studio for the project. What do I change to make Visual Studio recognize includes for QtScript? Currently, it reports that the…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
1
vote
0 answers

Typed array in QTScript

I have a javascript library that reads and writes C++ style data in binary format from/to a file. To do that, I use typed arrays (float32array,arraybuffer...). I need to port this library to QtScript. QTScript is supposedly compliant with ECMA-262…
Philemo
  • 11
  • 2
1
vote
0 answers

ReferenceError: Can't find variable: QTimer - why is Qtimer not available to my scripts?

I tried this snippet suggested elsewhere on SO: var timer = new QTimer(); timer.interval = 100; // set the time in milliseconds timer.singleShot = true; // in-case if setTimout and false in-case of setInterval timer.timeout.connect(this,…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
1
vote
1 answer

override operator with qtscript

I want do a math editor using qtscript. It will support array calculating in script. Such as array1 + array2 = array3.({1,2,3}+{3,4,5} = {4,6,8}); Maybe I need override operator+, I consult the example of QByteArray, and I override operator+,but…
andy
  • 11
  • 2
1
vote
1 answer

Passing a QObject to an Script function with QJSEngine?

I'm trying to call a function in an external script while passing a QObject as a parameter. My QObject is defined as this: #ifndef INSERTVALUES_H #define INSERTVALUES_H #include struct insertValueDef { QString name; QString xmlCode; …
QLands
  • 2,424
  • 5
  • 30
  • 50
1
vote
0 answers

Building qtcreator from source

So I was trying to build qtcreator from source, I compiled all the dependencies and moved on to compile qtcreator. I got this weird error when i ran qmake Project ERROR: Unknown module(s) in QT: script I did a little googling and found since I've…
compiler
  • 486
  • 1
  • 4
  • 14
1
vote
1 answer

How do I include the QtScript module in a Qt 5.4 application

Prior to Qt 5.4, I could add the QtScript module to my build by adding QT += script to my .pro file. However when I tried to build a project with Qt 5.4, 'script' is flagged as a unknown module by qmake. I can see the QtScript shared object in my…
David V
  • 486
  • 4
  • 17
1
vote
0 answers

Qt script destructor of own class is not called

I am using qtscript4 and have added some types to the engine. I registered a function that creates a new object and registered it on the engine with passing ownership to the engine. But the object seems not to get destroyed then leaving scope (at…
vlad_tepesch
  • 6,681
  • 1
  • 38
  • 80
1
vote
0 answers

Qt Script destructor of C++ object

I have a subclass of a QObject which I can already create in QtScript using var x = new Test(); I made a constructor function and registered it using QScriptEngine::​newFunction and QScriptEngine::​newQMetaObject like this: QScriptValue…
Nazar554
  • 4,105
  • 3
  • 27
  • 38