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 6174941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:50:14+00:00 2026-05-23T23:50:14+00:00

I have a program which interfaces with a radio I am using via a

  • 0

I have a program which interfaces with a radio I am using via a gui I wrote in PyQt. Obviously one of the main functions of the radio is to transmit data, but to do this continuously, I have to loop the writes, which causes the gui to hang. Since I have never dealt with threading, I tried to get rid of these hangs using QCoreApplication.processEvents(). The radio needs to sleep between transmissions, though, so the gui still hangs based on how long these sleeps last.

Is there a simple way to fix this using QThread? I have looked for tutorials on how to implement multithreading with PyQt, but most of them deal with setting up servers and are much more advanced than I need them to be. I honestly don’t even really need my thread to update anything while it is running, I just need to start it, have it transmit in the background, and stop it.

  • 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-23T23:50:16+00:00Added an answer on May 23, 2026 at 11:50 pm

    I created a little example that shows 3 different and simple ways of dealing with threads. I hope it will help you find the right approach to your problem.

    import sys
    import time
    
    from PyQt5.QtCore import (QCoreApplication, QObject, QRunnable, QThread,
                              QThreadPool, pyqtSignal)
    
    
    # Subclassing QThread
    # http://qt-project.org/doc/latest/qthread.html
    class AThread(QThread):
    
        def run(self):
            count = 0
            while count < 5:
                time.sleep(1)
                print("A Increasing")
                count += 1
    
    # Subclassing QObject and using moveToThread
    # http://blog.qt.digia.com/blog/2007/07/05/qthreads-no-longer-abstract
    class SomeObject(QObject):
    
        finished = pyqtSignal()
    
        def long_running(self):
            count = 0
            while count < 5:
                time.sleep(1)
                print("B Increasing")
                count += 1
            self.finished.emit()
    
    # Using a QRunnable
    # http://qt-project.org/doc/latest/qthreadpool.html
    # Note that a QRunnable isn't a subclass of QObject and therefore does
    # not provide signals and slots.
    class Runnable(QRunnable):
    
        def run(self):
            count = 0
            app = QCoreApplication.instance()
            while count < 5:
                print("C Increasing")
                time.sleep(1)
                count += 1
            app.quit()
    
    
    def using_q_thread():
        app = QCoreApplication([])
        thread = AThread()
        thread.finished.connect(app.exit)
        thread.start()
        sys.exit(app.exec_())
    
    def using_move_to_thread():
        app = QCoreApplication([])
        objThread = QThread()
        obj = SomeObject()
        obj.moveToThread(objThread)
        obj.finished.connect(objThread.quit)
        objThread.started.connect(obj.long_running)
        objThread.finished.connect(app.exit)
        objThread.start()
        sys.exit(app.exec_())
    
    def using_q_runnable():
        app = QCoreApplication([])
        runnable = Runnable()
        QThreadPool.globalInstance().start(runnable)
        sys.exit(app.exec_())
    
    if __name__ == "__main__":
        #using_q_thread()
        #using_move_to_thread()
        using_q_runnable()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which needs to behave slightly differently on Tiger than on
I have a program which deliberately performs a divide by zero (and stores the
I have a program which has some Textareas / Labels these can be anywhere
I have a program which needs installing on windows 64 boxes. Most of the
I have a program which only needs a NotifyIcon to work as intended. So
Consider this problem: I have a program which should fetch (let's say) 100 records
I have an AppleScript program which creates XML tags and elements within an Adobe
I have a program in which I've lost the C++ source code. Are there
I have a program in which the user adds multiple objects to a scene.
I am learning C# as I write a program which interfaces with a spectrometer.

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.