利用Accepted信号判断enterBtn是否被按下

来源:百度文库 编辑:神马文学网 时间:2024/04/23 20:24:26
【摘要】      这篇文档主要是在qtcreator编程时碰到这条语句   if(my1.exec()==QDialog::Accepted) ,程序在D:\Qt\2010.04\qt\nGui里面;【思路】myl这个对象是在main.cpp文件中定义的:myDlg myl; //建立自己新建的类的对象myl; Edit->Find/Replace->Adavanced  Find ->current Project   在里面进行搜索myDlg;在第三行的D:\Qt\2010.04\qt\nGui\mydlg.h下的第10行:class myDlg : public QDialog ;这表明这个myDlg是继承QDialog这个类的;所有QDialog这个类的函数myDlg都可以拿来用;welcome ->edit--->design--->debug---->projects--->help  进入help,在look for 输入QDialog;在下面找到这个函数exec();

int QDialog::exec ()   [slot] //这是个槽,本质上就是一普通的成员函数

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.中文翻译:如果这个对话框是程序模式,用户不能在同一个应用程序里访问其它窗口,除非我们把这个对话框关闭;                  如果这个对话框是窗口模式,只要这个对话框是处于打开状态的,它就不能和父窗口进行通信;PS:modal dialog包括window modal,application modal;

void QDialog::accepted ()   [signal]//这是个信号,本质上也就是成员函数

This signal is emitted when the dialog has been accepted either by the user or by calling accept() or done() with the QDialog::Accepted argument.

Note that this signal is not emitted when hiding the dialog with hide() or setVisible(false). This includes deleting the dialog while it is visible.