I implemented something similar to script console example in my application. I have GUI app with script editor. The problem is that the running script is blocking my GUI app (for ex. time.sleep(x))and I need scripts working in background necessarily.
I was trying to move all PythonQt code (includint PythonQt::init)from Main Thread to new Python thread (exactly to run method) but sth is wrong. Especially with:
console = new PythonQtScriptingConsole(NULL, mainContext);
I got error when starting thread:
QObject::setParent: Cannot set parent, new parent is in a different thread
So, PythonQt can work only from Main Thread? I am new in Qt and I don't know how to make this code work in backgroung.
Best regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I implemented something similar to script console example in my application. I have GUI app with script editor. The problem is that the running script is blocking my GUI app (for ex. time.sleep(x))and I need scripts working in background necessarily.
I was trying to move all PythonQt code (includint PythonQt::init)from Main Thread to new Python thread (exactly to run method) but sth is wrong. Especially with:
console = new PythonQtScriptingConsole(NULL, mainContext);
I got error when starting thread:
QObject::setParent: Cannot set parent, new parent is in a different thread
So, PythonQt can work only from Main Thread? I am new in Qt and I don't know how to make this code work in backgroung.
Best regards
Hello,
Scripts works ok in QThread, but I can not use console from QThread only. That is no problem, I redirect StdOut and StdErr.