Skip to content Skip to sidebar Skip to footer

How Can I Pass Arguments To Qthread Worker Class?

I have a working example of code that creates a QThread that must be called from my on class (MyClass). I have tried passing additional arguments through the Worker init, but I ca

Solution 1:

No, I think is not duplicated question, it have more to do ...

Anyway, Your question your want to pass more argument, In python your can pass many argument call 'yourMethod(*args, **kw)'; example;

classWorker(QThread):
    .
    .
    def__init__(self, parent, *args, **kw):
        QThread.__init__(self, parent)
        self.yourInit(*args, **kw)
    .
    .
    defyourInit(self, x, y, z):
        print x, y, z
    .
    .

classMyClass(QObject):
        .
        .
    def__init__(self):            
        super(MyClass, self).__init__()   
        .
        .
        x = 1000
        y = 'STRING'
        z = [0, 1, 2, 3, 4]
        thread1 = Worker(self, x, y, z)
        .
        .

Regards,

Post a Comment for "How Can I Pass Arguments To Qthread Worker Class?"