I have a Qt application with an embedded script/jit. Now I’d like to receive the output from the script on an QTextEdit (more specific QPlainTextEdit). For this purpose callbacks are being issued. The problem I’m facing is that whatever I try the output to the TextEdit is either delayed until the script has finished or gets stuck after 2-3 seconds (and is delayed then until the script has finished).
I tried to use signals and slots for the update but also direct function calls – neither worked. Also repainting / updating the TextEdit and the parent form as well as even QCoreApplication::flush() did show little/no effect. Seems like I’m doing something fundamentally wrong. Any ideas or examples how to achive the “real time” updates?
Btw, the update routines are being called – debug output to stdout is avaiable in real time.
Just to sketch a soluting using threads, which I have used numerous times for logging purposes and which works as desired:
Define your thread class:
Whenever you want a log message to be shown in the main thread, just use
emit signalLogMessage("Foo!");In your main thread:
where
logMessageFromThreaddoes something likemyPlainTextEdit->appendPlainText(message).This works without any delay or other problems.
I hope that helps.