【问题标题】:QProgressDialog "closes" when another process is startedQProgressDialog 在另一个进程启动时“关闭”
【发布时间】:2013-09-29 03:14:19
【问题描述】:

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

编辑:很明显,对话框并没有关闭,它只是主窗口优先并“覆盖”了对话框......如果这有意义的话。有什么办法可以让对话框保持显示优先级?

感谢您的宝贵时间 :)

【问题讨论】:

    标签: c++ qt process modal-dialog


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2015-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多