I have a process (a websocket) running in a Qthread class. What I want to do now is to edit some GUI items to be able to print the data im receiving. Since you should only edit widgets from the main class, I was thinking about sending variables from the thread to MainWindow. However, ive been failing at it, even after following some other posts here.
so far my post looks like this:
class Worker(QObject):
finished = pyqtSignal()
progress = pyqtSignal(int)
def __init__(self, parent = None):
# Inherits a variable from the main window
def run(self):
# websocket function goes here
self.finished.emit()
and then in my main class I have:
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): # Functions related to the class
def runLongTask(self):
self.thread = QThread()
self.worker = Worker(self.symbol)
self.worker.moveToThread(self.thread)
self.thread.started.connect(self.worker.run)
self.worker.finished.connect(self.thread.quit)
self.worker.finished.connect(self.worker.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
self.thread.start()