c++ - 显示对话框时如何禁用 Qt 应用程序中的用户交互?

标签 c++ qt dialog modeless

我有一个无模式的 QDialog 框,它在我的 Qt 应用程序中弹出错误/警告,我想强制用户只关注该对话框,而不是单击应用程序中的任何内容,直到他们在对话框上单击确定。

我需要对话框保持无模式。隐藏主窗口或将其覆盖等解决方案是 Not Acceptable 。

目前我正在使用 setModal(true); 来解决我的问题。但我认为此方法可能会阻止主应用程序执行。

最佳答案

来自documentation :

If you use show() and setModal(true) together to perform a long operation, you must call QApplication::processEvents() periodically during processing to enable the user to interact with the dialog.

关于c++ - 显示对话框时如何禁用 Qt 应用程序中的用户交互?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14818542/

相关文章:

c++ - Qt - 应用程序代码的正确设计

dialog - Xpages - 打开对话框几秒钟然后再次关闭

c++ - Qt 处理文件

c++ - 计算 C 数组中三元组的频率以进行索引

c++ - 无限滚动 QListWidget

android:如何调整对话框的大小

android - 对话框 fragment 中的自动完成 TextView 显示 Android 中的建议

c++ - 如何在数组中使用指针?

c++ - atomic_store() 等非成员函数的用途

c++ - 在 Release 中作为 QImage 加载时,相同的图像具有不同的像素数据