how to use qtimer in thread python

Solutions on MaxInterview for how to use qtimer in thread python by the best coders in the world

showing results for - "how to use qtimer in thread python"
Dale
22 Feb 2018
1class DataCaptureThread(QThread):
2    def collectProcessData(self):
3        print ("Collecting Process Data")
4
5    def __init__(self, *args, **kwargs):
6        QThread.__init__(self, *args, **kwargs)
7        self.dataCollectionTimer = QTimer()
8        self.dataCollectionTimer.moveToThread(self)
9        self.dataCollectionTimer.timeout.connect(self.collectProcessData)
10
11    def run(self):
12        self.dataCollectionTimer.start(1000)
13        loop = QEventLoop()
14        loop.exec_()
15