bibbinator
22nd June 2015, 17:12
Hi,
I want threaded execution of long-running scripts and am unsure the best way to do this in Qt.
In my app I want to allow users to write scripts in javascript that modify data in my app. Each script can show some settings which are defined in QML. Multiple scripts can be applied to the same data.
The scripts are invoked whenever the data is modified and is considered a long-running process. Since there are potentially many such scripts being applied to a data set, I would like to have the scripts be threaded.
I saw this which outlines the options: http://doc.qt.io/qt-5/threads-technologies.html
I see I can use a WorkerScript to run the user's script from QML but:
* It looks like I can't have the script post progress back to the QML UI such as a progress bar?
* No way to cancel or restart in the event the user changes the settings while the WorkerScript is running?
* No way to have the source be anything other than a standalone file? [it's messy to require multiple files per data filter and was hoping for a single file solution]
I see QtThread but:
* Is there a way to invoke a JS method from a thread and get updates/progress/cancel, etc.?
* This wants a C++ method but I want to use a script, so it means I need to create a new context within the thread and this seems really bad/inefficient?
I see QtConcurrent but:
* Is there a way to invoke a JS method from within this and still get updates/progress/cancel, etc.?
* This wants a C++ method but I want to use a script, so it means I need to create a new context within the thread and this seems really bad/inefficient?
Or is there a better way to run a script that's callable, cancelable, reports progress and can be multi-threaded?
All help appreciated!
Brett
I want threaded execution of long-running scripts and am unsure the best way to do this in Qt.
In my app I want to allow users to write scripts in javascript that modify data in my app. Each script can show some settings which are defined in QML. Multiple scripts can be applied to the same data.
The scripts are invoked whenever the data is modified and is considered a long-running process. Since there are potentially many such scripts being applied to a data set, I would like to have the scripts be threaded.
I saw this which outlines the options: http://doc.qt.io/qt-5/threads-technologies.html
I see I can use a WorkerScript to run the user's script from QML but:
* It looks like I can't have the script post progress back to the QML UI such as a progress bar?
* No way to cancel or restart in the event the user changes the settings while the WorkerScript is running?
* No way to have the source be anything other than a standalone file? [it's messy to require multiple files per data filter and was hoping for a single file solution]
I see QtThread but:
* Is there a way to invoke a JS method from a thread and get updates/progress/cancel, etc.?
* This wants a C++ method but I want to use a script, so it means I need to create a new context within the thread and this seems really bad/inefficient?
I see QtConcurrent but:
* Is there a way to invoke a JS method from within this and still get updates/progress/cancel, etc.?
* This wants a C++ method but I want to use a script, so it means I need to create a new context within the thread and this seems really bad/inefficient?
Or is there a better way to run a script that's callable, cancelable, reports progress and can be multi-threaded?
All help appreciated!
Brett