PySide Signals not being sent to Slot, from QThread object.

  • Hello,

    I'm working with a multi-threading application, where a worker thread gets created, that emits a signal.
    After creating the thread, I connect the signal with an object slot, that will perform some action.

    The problem, is the object slot, is not called, can someone help to figure out what's wrong ?

    import time
    from PySide import QtCore
    from PySide.QtCore import Slot, Signal
    class Worker1(QtCore.QThread):
        task_done_signal = Signal(int)
        def __init__(self):
            super(Worker1, self).__init__()
            self._run = False
        def run(self):
        def _loop(self):
            count = 0
            while self._run:
                count += 1
        def start(self):
            self._run = True
            super(Worker1, self).start()
        def stop(self):
            self._run = False
    class Worker1Listener(QtCore.QObject):
        def __init__(self):
            super(Worker1Listener, self).__init__()
        def print_task(self, val):
            print("listener: {}".format(val))
    def test_signals_and_threads():
        # create the thread
        worker = Worker1()
        # create the listener
        listener = Worker1Listener()
        # connect the thread signal with the slot
    if __name__ == '__main__':

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    There's no event loop running at all. Therefore signals and slots won't be working.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.