Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Help understanding Qthread, Pyside

Help understanding Qthread, Pyside

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dorothyang
    wrote on last edited by
    #1

    i am trying to understand how to do a Qthread and i have this skeletal code. my main objective is to not let the GUI "hang" while the backend is doing some database stuff and at the same time updating a table widget in the GUI. background: Doing this on Windows OS. Pyside as the GUI. (I also tried Python threading, but everytime my application crashes)

    @class GenericThread(QtCore.QThread):
    def init(self, function, *args, **kwargs):
    QtCore.QThread.init(self)
    self.function = function
    self.args = args
    self.kwargs = kwargs

    def __del__(self):
        self.wait()
    
    def run(self):
        self.function(*self.args,**self.kwargs)
        return
    

    clas myMainGUI(...)
    def add(self):
    ...
    for myfiles in os.listdir(..): <--- intensive process, lots of files
    column headers = [ .... ]
    result = select_data_from_file(myfiles) <----- database file processing
    self.insert_table_widget ( column headers, result ) <--want to insert to widge in "realtime" and do other stuff without GUI getting "hang"
    ....
    self.mythread.emit() <-- ??

     def coolie(self): # some button will call this function.
         if buttonclick == "add": 
            self.mythread = GenericThread(self.add)
            self.mythread.disconnect() <------??
            self.mythread.connect()  <------ ??
            self.mythread.start() @
    

    any idea how should my emit(), connect() or disconnect() be? thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved