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
0 answers

LESS - get CSS using Qt

I'm totally new in javascript so maybe my question is stupid. I want to use LESS to create CSS file. And I want to do it from my c++ code. So I'm using Qt and QtScript for it. 1) I can execute less.js in c++ using QScriptEngine. 2) I studied less.js…
bin-bin
  • 532
  • 2
  • 6
  • 16
1
vote
1 answer

Accessing not Non-QObject-based objects from Qt Script

Is there any nice and simple way to access non QObject-based classes, such as QXmlQuery, QDateTime etc. from Qt Script? The only way I see is to wrap QXmlQuery in another class that inherits QObject and declare as slot every function which I need to…
uni
  • 539
  • 1
  • 9
  • 21
1
vote
0 answers

Getting the anonymous function of an object in QtScript for later calling

How can i get the anonymous function placed into an object/variable and store it for later calling? Lets say i have this JS: callMeLater = function(){var foobar = "baz!";} How can i store callMeLater from my QScriptValue object? object.toString(),…
BastetFurry
  • 299
  • 3
  • 18
1
vote
0 answers

QtScript - calling slots from different thread

I have an application that uses QtScript. The QtScript is executed in seperated thread, this means that if I want to access slots from main threads widgets, I need some sort of sinhronization. In C++ this can easy be done with this: invokeMethod .…
UldisK
  • 1,619
  • 1
  • 17
  • 25
1
vote
2 answers

Add javascript support to existing QT application

I curently have a functional QT app, with several buttons. I need to control my application directly from javascript as the following example where AccessControl is my QObject class …
MokaT
  • 1,416
  • 16
  • 37
1
vote
2 answers

How can I call another QtScript .js file from one QtScript .js file

now I can use QScriptEngine to load and execute a test.js file. In one of the function of that test.js I'd like to call another function located in another .js file. How do I do this?
zhongzhu
  • 307
  • 2
  • 4
  • 14
1
vote
4 answers

QtScript can't call function with argument type "QString &"

I got below error "TypeError: cannot call sayHello(): argument 2 has unknown type `QString&' (register the type with qScriptRegisterMetaType())" when execute my Qt program test.exe to call a javascrip file haha.js. What I was trying to do is to…
zhongzhu
  • 307
  • 2
  • 4
  • 14
1
vote
1 answer

Context for an anonymous qt script function?

I'd like to execute an anonymous Qt script function from c++ but can't figure out the QScriptContext to use. Here's the script: { otherObject.Text = "Hello World"; setTimeout(function(otherObject) { otherObject.Text = "Goodbye World"; }, 9000…
Jay
  • 13,803
  • 4
  • 42
  • 69
1
vote
1 answer

Call object instance from C++ function called via script

I have a class named Jellyfish who use the singleton design pattern : jellyfish.h #ifndef JELLYFISH_H #define JELLYFISH_H #include #include class QScriptValue; class Jellyfish : public QObject { public: …
MARTIN Damien
  • 996
  • 2
  • 15
  • 36
1
vote
1 answer

How to make a class in Qt both scriptable and serializable?

I'm trying to write a class with two basic characteristics: It needs to be scriptable - the class contains a number of properties and methods decorated with Q_INVOKABLE that are exposed to scripts. It needs to be serializable so that it can be…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
1
vote
0 answers

Setting QObject ownship for QWebFrame javascript

I have a QObject that exists in a QWebFrame javascript environment through the addToJavaScriptWindowObject interface. This QObject has Q_INVOKABLE methods that return more QObject pointers (like a factory) that are used within javascript. Qt…
aughey
  • 458
  • 3
  • 8
1
vote
1 answer

what does "Making Applications Scriptable" mean and when should we use it?

Recently I noticed some classes in Qt which is called Qt script module and according to documentation it's used to make an application scriptable! here is my questions : What does it mean? making an application Scriptable? And when should we use…
s4eed
  • 7,173
  • 9
  • 67
  • 104
0
votes
0 answers

How much memory is taking a QScriptEngine environment?

Can i measure the total allocated memory by one QScriptEngine environment? I have a application with many instances of QScriptEngine in the same process and i need to known how much memory each instance uses.
0
votes
0 answers

QScriptEngine::evaluate("print(test)") not functional anymore

I need to migrate qt/4.8.6 code to qt/5.9 . I am struggling with using print statement within QScriptEngine evaluate statement. In simplified form implementation looks like: #include #include #include int…
0
votes
0 answers

How to solve memory leak with my data export function?

I run this code {in a for loop} that is made up of helper functions created by the commercial company Remcom. When I export my data sets, my RAM slowly fills up and I have to close the program (XFdtd) and restart it and restart the export function…