I've always wondered about what is the right way to share variable data with QThread and UI data. Well, for example,
#main.py
class MainUI(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
self.workerThread = Thread()
self.workerThread.mySignal.connect(self.function_name)
#worker.py
class Thread(QThread):
mySignal = pyqtSignal(str)
def __init__(self):
super().__init__()
def run(self):
self.mySignal.emit(some_string)
I know this code will emit and share "some_string" variable with MainUI class.
However; I don't think pyqt have an option to share variable data MainUI -> Thread
So, I am writing a code just like
self.workerThread.variable = None
What is desirable method to write a code?