I am trying to listen a serial port and write the listened things to QPlainTextEdit item in Qt, real-time. For that, I have created a thread that listens and writes what it listens to the QPlainTextEdit item using the method I created.
Thread:
def readPort_thread(self):
while self.printerOnline == True:
self.writeTerminal(str(self.ser.readline(),'utf-8'))
QPlainTextEdit writer method:
def writeTerminal(self,inputTxt):
if not inputTxt.endswith('\n'):
inputTxt = inputTxt + '\n'
self.textG.setPlainText(self.textG.toPlainText() + inputTxt)
self.textG.verticalScrollBar().setValue(self.textG.verticalScrollBar().maximum() - 1)
So, I have tried couple of different things and looked for web for it but couldn't find anything. As I understood, the problem is calling Qt element method from a thread. I am new to Qt. Thanks.