QDialog::exec() 阻止应用程序
QDialog::exec() blocks the application
我目前有一个formA,它使用从QDialog继承的另一个表单请求用户输入。使用QDialog::exec提示表单。现在的问题是,将有多个表单A实例,因此每当表单A中的任何一个打开另一个表单作为对话框时,整个应用程序都会阻止。目前我有这样的东西
if(formUserInputRequired->exec()==1) //Block until the user selects from a form
{
}
有没有办法使QDialog::exec不阻止整个应用程序,我只是希望它只阻止调用它的表单的实例或类似的东西,但绝对不是整个应用程序?
更新:我不需要阻塞窗口。但是,我想找到一种方法来知道用户何时完成另一种形式的输入,以便原始表单可以处理该数据
在对话框中调用 setWindowModality
方法,Qt::WindowModal
作为参数。
Qt::NonModal 0 The window is not modal and does not block input to other windows.
Qt::WindowModal 1 The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows.
Qt::ApplicationModal 2 The window is modal to the application and blocks input to all windows.
源
你可以改用 show(),然后为了获取对话框结果,你将接受信号连接到 formA 的插槽来处理它,就像:
connect(formUserInputRequired, SIGNAL(accept()), this, SLOT(acceptClicked());
formUserInputRequired->show();
将对话框的模态设置为Qt::WindowModal
(QDialog 的默认值为 Qt::ApplicationModal
)
您可以使用
show()
方法代替exec()
,因为exec
方法都有自己的事件循环。
相关文章:
- 试图在visual studio上用C++创建一个桌面应用程序
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 在C应用程序中运行C++(带有STL)函数
- 使用VerQueryValue检索应用程序的文件描述
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用调试/崩溃报告将应用程序部署到客户端
- C++控制台应用程序阻止退出
- 码头化的C++应用程序是否向后兼容早期的内核版本
- 将应用程序从32位移植到64位时出现问题
- 如何改变c++应用程序的视觉效果
- WM_CTLCOLORSTATIC从未在WIN32应用程序中触发
- PC中的程序和PHONE中的本机描述应用程序之间的数据连接
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- phytec phyBOARD iMX-6在从闪存而不是SD卡运行qt5 opengles应用程序时表现不佳(FPS减半
- 为什么导入Mixed native/CLR lib.dll的本机C++应用程序没有在Mixed lib.dll中的外部变
- 无法使用管道将数据发送到我通过exec(C++)启动的第二个应用程序
- 关闭Qt控制台应用程序会终止exec()调用中的进程,并且无法从main()扩展到范围
- QDialog::exec() 阻止应用程序
- 加载共享库时出错:cv2.所以使用php exec()为c++应用程序.在web应用程序