我有一个 Pyside6 应用程序,它应该运行一个子进程作为其功能的一部分。当子进程完成时,它应该触发信号
self.subprocess.finished
,但函数 notify_success_or_failure
没有运行,即使在进程完成后也是如此。
这是我的代码
def begin_subprocess(self, folder_path, return_to_path, return_path):
self.subprocess = QProcess()
# check what command needs to be run to start the subprocess
python_executable = sys.executable
# gather the parameters needed
paramaters = [folder_path, str(return_to_path), return_path]
command_info = [python_executable, "./true_run.py"]
command = command_info + paramaters
print(command)
# Connect the finished signal of the QProcess to the custom signal
self.subprocess.finished.connect(self.notify_success_or_failure)
# Start the subprocess asynchronously
self.subprocess.startDetached(command[0], command[1:])
我想说我已经尝试过一些事情,但我还没有做到。我不知道是什么导致了这个问题,可能是缺乏专业知识,如果这里有人比我更了解 pyside,那将非常感激。
显然,我使用了错误的启动方法,我错误地认为 startDetached 会在终端中启动它并允许用户与程序交互(它在侧面执行)。最后,结果发现
startDetatched
禁用了信号,谢谢musicamante。