Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3489548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:24:29+00:00 2026-05-18T11:24:29+00:00

I’m having some problems with communicating between Threads in PyQt. I’m using signals to

  • 0

I’m having some problems with communicating between Threads in PyQt. I’m using signals to communicate between two threads, a Sender and a Listener. The sender sends messages, which are expected to be received by the listener. However, no messages are receieved. Can anyone suggest what might be going wrong? I’m sure it must be something simple, but I’ve been looking around for hours and not found anything. Thanks in advance!

from PyQt4 import QtCore,QtGui
import time

class Listener(QtCore.QThread):    
    def __init__(self):
        super(Listener,self).__init__()

    def run(self):
        # just stay alive, waiting for messages
        print 'Listener started'
        while True:
            print '...'
            time.sleep(2)

    def say_hello(self):
        print ' --> Receiver: Hello World!'

class Sender(QtCore.QThread):
    # a signal with no arguments
    signal = QtCore.pyqtSignal()

    def __init__(self):
        super(Sender,self).__init__()
        # create and start a listener
        self.listener = Listener()
        self.listener.start()
        # connect up the signal
        self.signal.connect(self.listener.say_hello)
        # start this thread
        self.start()

    def run(self):
        print 'Sender starting'
        # send five signals
        for i in range(5):
            print 'Sender -->'
            self.signal.emit()
            time.sleep(2)
        # the sender's work is done
        print 'Sender finished'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:24:29+00:00Added an answer on May 18, 2026 at 11:24 am

    I’m not sure if that is what you need, but it works fine…

    from PyQt4 import QtCore,QtGui
    import time
    
    class Listener(QtCore.QThread):
        def __init__(self):
            super(Listener,self).__init__()
    
        def run(self):
            print('listener: started')
            while True:
                time.sleep(2)
    
        def connect_slots(self, sender):
            self.connect(sender, QtCore.SIGNAL('testsignal'), self.say_hello)
    
        def say_hello(self):
            print('listener: received signal')
    
    class Sender(QtCore.QThread):
        def __init__(self):
            super(Sender,self).__init__()
    
        def run(self):
            for i in range(5):
                print('sender: sending signal')
                self.emit(QtCore.SIGNAL('testsignal'))
                time.sleep(2)
            print('sender: finished')
    
    if __name__ == '__main__':
        o_qapplication = QtGui.QApplication([])
        my_listener = Listener()
        my_sender = Sender()
        my_listener.connect_slots(my_sender)
        my_listener.start()
        my_sender.start()
        i_out = o_qapplication.exec_()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.