QProgressDialog "closes" 当另一个进程启动时

QProgressDialog "closes" when another process is started

本文关键字:启动 进程 closes QProgressDialog 另一个      更新时间:2023-10-16

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

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