0

I tried following the solution laid out in this question, but nothing seems to happen once the signal is supposed to be emitted.

This isn't all of the code, but it should be enough to demonstrate what I'm trying to do:

class StartQT5(QMainWindow):
    def __init__(self):
        super().__init__()
        [...]
        self.getFileProperties(path, batch)

    def getFileProperties(self, path, batch):
        self.thread = QThread()
        self.w = probeThread(self)        
        self.w.moveToThread(self.thread)
        self.w.finished[dict].connect(self.setProbeOutput)
        self.thread.started.connect(self.w.run)
        self.thread.start()

    @pyqtSlot(dict)    
    def setProbeOutput(self, data):
        print("gotOutput")
        self.probeOutput = data
        print(data)

class probeThread(QObject):
    finished = pyqtSignal(dict)

    def __init__(self, parent):
        super().__init__()
        self.parent = parent
        self.output = {}

    def run(self):
        self.output = json.loads(subprocess.check_output('%s -v 0 -print_format json -show_format -show_streams -count_frames "%s"' % (self.parent.ffprobePath, self.parent.file)).decode("utf-8"))
        print("finished")
        self.finished.emit(self.output)

The thread runs fine, but setProbeOutput never gets called. Sorry if this is something trivial, but I just can't seem to get it to work, thanks! :)

maciozo
  • 45
  • 1
  • 8

1 Answers1

0

What about simply doing:

self.w.finished.connect(self.setProbeOutput)

You are defining a new signal and attaching it to a slot, you already declare the parameters types both in the signal and the slot declaration.

Daniele Pantaleone
  • 2,657
  • 22
  • 33