Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I searched on similar cases but i didnt find one that corresponds to the way i set up my application. In the below code, i call a QtWidgets.QDialog class from my main window. And after a button is pressed a heavy operation is starting. My problem is: how can i implement QThreads in my example? Can you please show me what i need to change? Since the heavy operation is called from my dialog and not from the main window class, how exactly can i use threads in here?


class MainScreen(QtWidgets.QMainWindow): 
 
    # do stuff 
 
 
    def caller(self): 
        dialog2 = OpenDialog(self, self.parameter) 
        dialog2.exec() 
        # do more stuff     
 
 
 
 
 
 
class OpenDialog(QtWidgets.QDialog): 
 
    def __init__(self, parent, parameter): 
        super().__init__(parent) 
        self.parameter = parameter 
        uic.loadUi('interface/dialog.ui', self) 
 
        self.pushButton.clicked.connect(self.heavy_function) 
    
 
 
 
    def heavy_function(self): 
        # do alot of stuff that take time 


What I have tried:

i tried searching for similar issues but i couldnt much my case with them.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900