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.
117
questions
1
vote
1
answer
166
views
TeXstudio macro script : how to move the cursor to specified position?
For example, I want to write the following macro in script in TeXstudio(using QtScript):
%SCRIPT
editor.write("\\textcolor{red}{}")
After invoking this macro, I want the cursor to move ...
0
votes
0
answers
143
views
Can't import a JS module with unknown types to QJSEngine
I create an extension class for QJSEngine that provides a function importModule() to engine's global object that works like an the standard import statement in JS.
The simplified version of this class ...
0
votes
0
answers
78
views
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 <iostream>
#...
2
votes
2
answers
1k
views
Qt Installer Framework: TypeError cannot read property name
I tried creating an installer following the tutorial. I then added a script called "installerscript.qs" as per the startmenu example in the Qt Installer Framework directory.
The "...
0
votes
0
answers
113
views
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) ...
0
votes
1
answer
195
views
passing QByteArray in arg with QScriptEngine
i will try to use QScriptEngine to write function to Read Array and write array to change Trame for example with qtscript user.
i have read lot of documentation.
i will try this:
for the moment, i ...
1
vote
1
answer
647
views
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") + ";" + ...
1
vote
1
answer
373
views
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);
~...
0
votes
1
answer
303
views
Is there any way to write a file with QtScript?
I want to make an installer with Qt. The configuration of the installer is written in a file named installscript.qs which is qtscript based
I tried to create a QFile inside but it didn't recognize it!
...
0
votes
1
answer
163
views
QT qScriptConnect is not working
QScriptEngine eng;
QScriptEngineDebugger debugger;
debugger.attachTo(&eng);
QScriptValue consoleObj = eng.newQObject(this);
eng.globalObject().setProperty("asd", consoleObj);
QScriptValue handler=...
0
votes
1
answer
1k
views
How to register a QMap inside of a QList as a Meta Type in QtScript?
I am looking at having a QList<QMap<QString, QString>> object passed from my Qt code to a JavaScript file and wondering how to properly handle the qScriptRegisterMetaType portion of the ...
0
votes
1
answer
88
views
How to include a Qt Core c++ class for use in QtScript user function in SQLiteStudio 3.1.1?
I'm trying to write a user-defined function within SQLiteStudio (v3.1.1). This function needs to decode a field stored in base64.
I think I can achieve what I want to using the QByteArray class from ...
0
votes
1
answer
86
views
How do I cast class method to QScriptEngine::FunctionSignature
I want to pass this method:
QScriptValue ScriptProcessContext::construct(QScriptContext * ctx, QScriptEngine *)
{
return this->newInstance();
}
to QScriptEngine::newFunction. I tried the ...
1
vote
0
answers
88
views
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 ...
0
votes
1
answer
318
views
How to iterate over items in QScriptValue which isArray()?
So I have this code:
QScriptValue result(someFunction());
if(result.isArray()) {
{
// Print items in array
}
How can I do it? I tried to convert it to QList<QScriptValue> but that doesn't ...
0
votes
1
answer
334
views
QScxml ECMAScript Data Model
I am having a look at QScxml ECMAScript Data Model and as I have never used any scripting functionality of Qt I am a bit lost.
I have seen that Qt has different Script engines (QtScript, QJSScript, ...
2
votes
1
answer
452
views
Qt Script Multithreading
I need to run multiple (up to 50 or more) Qt Script Functions concurrently. Running two or three Threads with Script Functions works just fine, but as soon as I run around 50 Threads, I get an Error ...
0
votes
1
answer
321
views
How to convert QVariant to native QtScriptValue (Number, String etc.)
I had some problem with validating values in my QtScript script. The validator function looked like this:
function isValueInvalid(value) {
return typeof value=="undefined" || value == null || ...
0
votes
0
answers
820
views
Transition from QtScript to QML/QJSEngine
There is some platform with use of QtScript as the JavaScript interpreter for the description of logic of the application.
Example of a script on JS
var f=new File('/var/www/test1');
f.write('123\n')...
6
votes
1
answer
461
views
Is there a way to maintain Qt script context environment outside of QScriptEngine#pushContext/popContext?
In Qt 4.8's scripting engine, "local" variables can be set by obtaining a QScriptContext from QScriptEngine::pushContext then setting the properties of its activation object. This can only be done ...
0
votes
1
answer
139
views
Setting QScriptValue-local values prior to evaluating
Is it possible, in Qt 4.8, from the C++ side, to set QScriptValue-local values in a QScriptEngine?
For example, let's say I have:
QScriptEngine engine;
engine.globalObject().setProperty("glob", 1000)...
2
votes
0
answers
583
views
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(...
11
votes
0
answers
1k
views
Debugging QJSEngine?
I have a project that provides a JS API for (long running) user scripts.
This project still uses the QtScript module which is kinda bugging me since the module is labeled deprecated for quite some ...
1
vote
2
answers
2k
views
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 ...
1
vote
0
answers
62
views
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....
0
votes
1
answer
568
views
Sockets comunication between QTScript and Python
I'm trying to communicate an external python script with a C++ program that allows qt-scripting. The goal its to partially control the C++ program (using its qtscript api functions) from python code.
...
1
vote
0
answers
55
views
ReferenceError: Can't find variable: QTimer - why is Qtimer not available to my scripts? [duplicate]
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 ...
2
votes
0
answers
1k
views
How to instantiate my C++ class from QtScript? My class inherits QObject
I am researching possibilities of QtScript. I understand that it is possible to create QObject in C++ and then pass it into QScriptEngine:
QObject *someObject = new WindowWithText;
QScriptValue ...
8
votes
1
answer
802
views
Can I use should.js with QtScript?
I'm using QtScript to automate parts of my application for development and testing purposes. I've come to the point where I want to test assertions, and based on "standalone assertion libraries?" and ...
1
vote
1
answer
2k
views
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 <QObject>
...
2
votes
1
answer
3k
views
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 <QCoreApplication>
#include <QtQml>
int ...
2
votes
0
answers
1k
views
QJSEngine vs QtScript and QList<MyClass>
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
{
...
0
votes
1
answer
154
views
Manipulate a 2d array from QtScript
I would like a way to be able to access an array of integers that is created somewhere in my main app from a QtScript, and after doing whatever manipulations that the script might perform return it ...
1
vote
0
answers
1k
views
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: ...
1
vote
1
answer
2k
views
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 ...
0
votes
1
answer
324
views
QWebView find text inside invisible elements
In my Qt project I'm using the QWebView to load my html table data.
I'm using the findText function to find text in the html page.
But, I can't find invisible text...
HTML sample :
<table>
...
0
votes
0
answers
113
views
int written to QVariantmap is not a number in Javascript
From a slot function that is accessible from javascript I return a QVariantMap since I want to be the data converted to JavaScript object that contains some primitives.
the code looks like the ...
1
vote
0
answers
120
views
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 ...
0
votes
1
answer
184
views
qtscript engine - make system calls
I use qtscript in an application to provide automation capabilities for various functions within the application.
To allow greater flexibility i need the possibility to execute other tools (...
1
vote
0
answers
285
views
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::...
1
vote
0
answers
168
views
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....
0
votes
1
answer
444
views
Access values created by QScriptEngine on heap?
[Question]
Suppose we feed QScriptEngine with the following script:
var foo = 1;
var bar = 2;
foo + bar
by QScriptEngine::evaluate(), we'll get a QScriptValue returned which can be translated back ...
3
votes
1
answer
747
views
How to emulate a shell-like scripting environment with QTextEdit? [duplicate]
[Goal]
A simple shell prompt with QTextEdit, or any other appropriate Qt ways.
(Using QScriptEngine as an ECMA script interpreter is assumed)
[Example]
MATLAB
Python
In a shell prompt, the command ...
3
votes
0
answers
619
views
How do I generate documentation screenshots for a Qt application?
Without manual intervention I would like to generate screenshots of a Qt desktop application. The screenshots should be generated when the make documentation make target is being issued. So in the ...
0
votes
1
answer
374
views
QScriptEngineAgent - obtaining callee name
I'm trying to implement a simple QtScript performance profiler via QScriptEngineAgent, by catching function entries and exits. I successfully subscribed to QScriptEngineAgent::functionEntry() callback....
7
votes
1
answer
2k
views
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 ...
3
votes
0
answers
466
views
Getting "destroyed" signal in Qt Script
How to properly connect to QObject's destroyed signal from Qt Script?
When I connect to it like to your average signal, it does not work. I did test that I removed the object and that other QObjects ...
0
votes
1
answer
144
views
Can I use QScriptEngine.toScriptValue with a QPointer to a QObject?
The documentation on working with QtScript and converting back and forth between script values and C++ mentions that you can use QScriptEngine.toScriptValue with a QObject* type and have it work ...
0
votes
1
answer
148
views
Can I add a new value to a QObjectList from QtScript?
The function qScriptValueFromSequence allows me to create an array in QtScript from a QObjectList, where the QObject properties change when I modify them in script. If a user adds a new object to the ...
1
vote
0
answers
100
views
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 ...