示例#1
0
def finished():
    print("post thread: %d" % QThread.currentThreadId())
示例#2
0
 def run(self):
     print("job thread: %d" % QThread.currentThreadId())
     self.finished.emit()
示例#3
0
from qt.QtCore import (QThread, QObject, QCoreApplication, QMetaObject, Qt,
                       Slot, Signal, QRunnable, QThreadPool)


class Job(QObject):

    finished = Signal()

    @Slot()
    def run(self):
        print("job thread: %d" % QThread.currentThreadId())
        self.finished.emit()


def finished():
    print("post thread: %d" % QThread.currentThreadId())


if __name__ == '__main__':
    import sys
    app = QCoreApplication(sys.argv)
    print("main thread: %d" % QThread.currentThreadId())
    thread = QThread()
    thread.start()
    job = Job()
    job.finished.connect(finished, Qt.QueuedConnection)
    job.moveToThread(thread)
    QMetaObject.invokeMethod(job, 'run', Qt.QueuedConnection)
    app.exec_()
    thead.wait()
示例#4
0
文件: dothread.py 项目: Answeror/lit
def finished():
    print("post thread: %d" % QThread.currentThreadId())
示例#5
0
文件: dothread.py 项目: Answeror/lit
 def run(self):
     print("job thread: %d" % QThread.currentThreadId())
     self.finished.emit()
示例#6
0
文件: dothread.py 项目: Answeror/lit
    QThreadPool
)


class Job(QObject):

    finished = Signal()

    @Slot()
    def run(self):
        print("job thread: %d" % QThread.currentThreadId())
        self.finished.emit()


def finished():
    print("post thread: %d" % QThread.currentThreadId())


if __name__ == '__main__':
    import sys
    app = QCoreApplication(sys.argv)
    print("main thread: %d" % QThread.currentThreadId())
    thread = QThread()
    thread.start()
    job = Job()
    job.finished.connect(finished, Qt.QueuedConnection)
    job.moveToThread(thread)
    QMetaObject.invokeMethod(job, 'run', Qt.QueuedConnection)
    app.exec_()
    thead.wait()