利用 exec() 函数,exec()函数解释如下:
[virtual slot] int QDialog::exec()
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.
Note: Avoid using this function; instead, use open(). Unlike exec(), open() is asynchronous, and does not spin an additional event loop. This prevents a series of dangerous bugs from happening (e.g. deleting the dialog’s parent while the dialog is open via exec()). When using open() you can connect to the finished() signal of QDialog to be notified when the dialog is closed.
See also open(), show(), result(), and setWindowModality().
大致意思:将 窗口 以模态显示,阻塞程序直到窗口关闭。若窗口为 application 模式(无父窗口),则在关闭该窗口之前,不能操作其他任何窗口;若窗口为 window 模式(有父窗口),则在关闭该窗口之前,不能操作其父窗口。
返回值:
QDialog::Accepted 1
QDialog::Rejected 0