Here is a more refined version of the question.
I have a .ui object with a QTextEdit in the main thread.
I have a separate thread with a script that needs to add data to the QTextEdit. I know I can communicate across threads with signal/slots in C++ but I am unsure if it is possible or the syntax needed to do so from a script that is signaling from a separate thread.
Reading the docs on "Making Applications Scriptable" it makes reference to but I am unsure of the syntax. Here is a guess at it.
Script File:
function main(ui) {
this.ui = ui;
ui.myQTextEdit.setText.connect(mySetText);
}
function mySetText() {
// text to be signaled to the ui object across threads
}
function main(ui) {
this.ui = ui;
ui.myQTextEdit.setText.connect(mySetText);
}
function mySetText() {
// text to be signaled to the ui object across threads
}
To copy to clipboard, switch view to plain text mode
If I do something like:
ui.myQTextEdit.setText('my new text');
ui.myQTextEdit.setText('my new text');
To copy to clipboard, switch view to plain text mode
I get the dreaded QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTextDocument(0x8601fc8), parent's thread is QThread(0x849a470)
Any insight would be greatly appreciated.
Bob
Bookmarks