繁体   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