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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:47:35+00:00 2026-05-27T00:47:35+00:00

i have a QMainWindow that starts a QThread and waits for data from the

  • 0

i have a QMainWindow that starts a QThread and waits for data from the network. updates UI when it receive any data.

the problem is : it sometimes crash. and sometimes doesn’t , all i do i start it and wait for data.

here is the thread class :

class ListenerThread(QtCore.QThread):

        def __init__(self,host,port,window):
            super(ListenerThread,self).__init__(window)
            self.host = host
            self.port = port
            self.window = window


        def run(self):

            soc = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
            soc.bind((self.host, self.port))

            while True:

            data, address =  soc.recvfrom(9999)
            print address


            if data:



                dataList = data.split("\\")


                company  = dataList[1] 
                projectName = dataList[2]  
                assets = dataList[3]  
                assetType = dataList[4]  
                assetName = dataList[5] 



          # parent here is the main window(the main thread) : updateCombo is a function that updates combo box inside the               main window 

                self.parent().updateCombo(self.window.comboBoxCompany,company)
                self.parent().updateCombo(self.window.dropDownProjects,projectName)

                self.parent().select(assets,assetName)

why is this happening ?? put in mind that the main Window by itself works fine.

the function (updateCombo) is working fine also ( when you call it from it’s class).

but main window keeps crashing when i send data ! any idea why ?

  • 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-27T00:47:36+00:00Added an answer on May 27, 2026 at 12:47 am

    GUI widgets may be accessed only from main thread, meaning the thread that calls QApplication.exec(). Access to GUI widgets from any other thread – what you’re doing with your calls to self.parent() – is undefined behaviour, in your case this means crashes.

    You signals and slots to communicate between background threads and the GUI in a safe manner.

    And please read the documentation about Qt’s threading functionality, because the above is actually essential knowledge when dealing with multi-threaded GUI applications, not only in Qt, but in any other GUI framework, too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that starts with a tableview (from a xib) that loads
I would like to have a QMainWindow that can change it's look at runtime,
I have a class that inherits QMainWindow and I just want it to have
I have simple drag and drop functions implemented in QmainWindow the reference taken from
I have a QMainWindow that connects 2 buttons with 2 functions. I want to
I have a view that is loaded in the MainWindow.xib. It is just a
i have a QMainWindow. It has this parameters: this->setWindowFlags(Qt::Tool); this->setFocusPolicy(Qt::StrongFocus); this->setAttribute(Qt::WA_QuitOnClose,true); After showEvent calles
I have a QMainWindow which spawns a few wizards. The QMainWindow has a QFrame
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Hi all I have problem with qprogressbar. How can I make it smooth? I

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.