簡體   English   中英

啟動另一個進程時,QProgressDialog“關閉”

[英]QProgressDialog “closes” when another process is started

在我的項目中,我正在運行一個函數,同時QProgressDialog顯示進度。

QProgressDialog progress("Saving savegame.dat...", "Abort Save", 0, 3016, this);
        progress.setWindowModality(Qt::WindowModal);

//... some loops and other calculations run while I update the progress bar with:
progress.setValue(1000);

一切順利,直到我開始另一個過程。 (打開一個cli程序)

QProcess decomBR;
QStringList filePathListBR;
filePathListBR.append("-o");
filePathListBR.append("stuff\\compress.bms");
filePathListBR.append("stuff\\regions\\xbox_chunks\\br");
filePathListBR.append("stuff\\regions\\xbox_chunks\\br");
decomBR.start("stuff\\quickbms.exe", filePathListBR);
decomBR.waitForFinished();

一旦啟動了這樣的過程,進度條對話框就會隱藏或出現某種情況,並且不再顯示進度,但是過程仍然可以正常運行。

有什么方法可以防止這些進程“關閉” QProgressDialog?

編輯:所以很明顯,對話框沒有關閉,只是主窗口處於優先地位,並且“覆蓋”對話框...如果那是有道理的。 有什么方法可以使對話框保持顯示優先級?

謝謝你的時間 :)

我沒有嘗試過,但是setWindowFlags(Qt::WindowStaysOnTopHint); 可能會有所幫助。 請注意,這是一個標志,因此您需要編寫如下代碼:

progress.setWindowsFlags( progress.getWindowsFlags() | Qt::WindowStaysOnTopHint );

考慮使用一個斷言來查看它是否已經設置,如果是這樣,那么您可以確定地拒絕我的回答,並通過否定來增加人類的知識!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM