当另一个进程启动时,QProgressDialog“关闭”

时间:2013-09-29 03:14:19

标签: c++ qt process modal-dialog

在我的项目中,我有一个正在运行的函数,而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?

编辑:显然,对话框没有关闭,只是主窗口正在优先处理并“覆盖”对话框...如果这是有意义的。有没有办法让对话框保持显示优先级?

感谢您的时间:)

1 个答案:

答案 0 :(得分:0)

我没有尝试过,但setWindowFlags(Qt::WindowStaysOnTopHint);可能有所帮助。请注意,它是一个标志,因此您需要编写如下内容:

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

考虑使用断言来查看它是否已经设置,如果是,那么你可以明确地驳回我的答案并通过否定来增加人类的知识!

相关问题