c++ - 打开另一个表单,然后等待该表单返回响应

标签 c++ qt

我目前有一个表单 A 需要一些输入。但是,为了获得该输入,需要填写另一个表格 B。所以我想要的是当用户单击 formA 中的按钮然后显示 formB 时。现在,当单击表单 B 中的按钮时,结果将返回到表单 A。做这个的最好方式是什么。 ?目前我有一个只显示表单 B 的表单,然后我就卡住了。有什么建议吗?

最佳答案

你可能想继承formB来自 QDialog上课然后打电话exec()而不是 show() .

来自 docs :

Shows the dialog as a modal dialog, blocking until the user closes it. The function returns a DialogCode result.

If the dialog is application modal, users cannot interact with any other window in the same application until they close the dialog. If the dialog is window modal, only interaction with the parent window is blocked while the dialog is open. By default, the dialog is application modal.

与此结合,您可能需要使用 QDialog::accept , QDialog::rejectQDialog::setResultformB为了将结果传递给 formA .

关于c++ - 打开另一个表单,然后等待该表单返回响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18345528/

相关文章:

c++ - 未找到 inputRejected 信号

qt - 如何将DLL添加到Qbs项目中

c++ - QObject::connect: 无法对类型为 'int&' 的参数进行排队

c++ - 从 C++ 解压 ZIP 的最简单方法?

C++比较并替换stringstream的最后一个字符

c++ - 将 ISO 8859-X 转换为 UNICODE 的方法

c# - 在 C# 程序中避免这种竞争条件

c++ - QMediaPlayer 和 gstreamer 系统崩溃

python - 在 Qt 中启动单独的进程

c++ - 使用 'using' 关键字获取指向类方法的指针