問題描述
如果我使用 startDetached() 啟動 QProcess,我會收到完成的信號嗎?我正在嘗試啟動一個進程,但我需要能夠在進程終止時獲得一個事件.
Do I get a finished signal if I start a QProcess using startDetached()? I'm trying to start a process, but I need to be able to get an event when the process has terminated.
推薦答案
不,當你使用 startDetached 時無法得到信號,因為你沒有對象.
No you can't get a signal when you use startDetached because you have no object.
startDetached 是一個靜態函數,當您調用它時,進程會直接啟動,而無需創建 QProcess 對象.因此,即使有信號,您也無法將其連接到任何東西,因為您沒有要連接的對象.
startDetached is a static function and when you call it the process is started directly without creating a QProcess object. Therefore, even if there was a signal you would not be able to connect it to anything since you have no object to connect from.
如果你想要一個信號,你應該創建一個 QProcess 對象,然后在它上面調用 start.當進程完成時,您將能夠獲得完成的信號.
If you want a signal you should create a QProcess object and then call start on it. You will then be able to get the finished signal when the process finishes.
這篇關于如果我使用 startDetached 啟動 QProcess,我會得到一個完成的插槽嗎的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!