I'm trying to use QProcess to run a class method in a separate process. I know that the following code won't work but I am wondering if there is a tweak for starting a new process by QProcess rather than using multiprocessing.process(target=function_name)
import multiprocessing
from PyQt5 import QtCore
class myClass:
def __init__(self):
self.x = 20
def loop(self,):
for i in range(1,1000):
self.x = i
M = MyClass()
# p = multiprocessing.process(target=MyClass.loop) # Is QProcess capable of doing this?
p = QtCore.QProcess(myClass.loop) # I know this won't work but I am looking for a way to use QProcess for ths purpose
p.start()