Using QProcess.finished() in Python 3 and PyQt

一曲冷凌霜 提交于 2019-12-06 06:13:24
Alexander Lutsenko

You can't get a signal when you use startDetached() because you have no object. Use ordinary start() instead.

And don't forget to start QApplication within control script, too.

class Control(QObject):
    def properties(self):
        self.process=QProcess()
        self.process.finished.connect(self.onFinished)
        self.process.start('python3', ['../GUI/main.py'])

    def onFinished(self,  exitCode,  exitStatus):
        [...]

if __name__ == '__main__':
    app = QApplication(sys.argv)

    co = Control()
    co.properties()

    sys.exit(app.exec_())
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!