im trying to send "append" to qmainwindow from a qthread. the code seems like working but i get this error msg everytime i use append in qthread.
QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().)
tried to search on google and i figured you need signal and slot but its hard for me to understand as im not a native english speaker and theres not enough information about it in my native language. i would really appreciate if someone could fix my code with explanation! thankyou
import time as time
import sys
from PyQt5 import uic
from PyQt5.QtTest import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
form_class = uic.loadUiType("test.ui")[0]
class Worker(QThread):
def __init__(self, parent):
super().__init__(parent)
self.parent = parent
self.running = False
def run(self):
while self.running:
self.parent.testbrowser.append("test msg")
time.sleep(1)
def pause(self):
self.running = False
class WindowClass(QMainWindow, form_class) :
def __init__(self) :
super().__init__()
self.setupUi(self)
self.btntest.clicked.connect(self.btntestfunction)
self.btntest_2.clicked.connect(self.btntest2function)
self.worker = Worker(self)
def sleep(self,n):
self.testbrowser.append("waiting")
QTest.qWait(n*1000)
def btntestfunction(self):
self.testbrowser.append("start")
self.worker.running = True
self.worker.start()
def btntest2function(self):
self.testbrowser.append("pause")
self.worker.running = False
self.worker.pause()
if __name__ == "__main__" :
app = QApplication(sys.argv)
myWindow = WindowClass()
myWindow.show()
app.exec_()