函数调用在哪里发生?

时间:2011-04-18 08:32:10

标签: c++ qt function

在以下来自 C ++ GUI Programming with Qt 4 的代码中,on_lineEdit_textchanged()函数的调用发生在哪里,因为它没有在代码中明确显示?

#include <QtGui>
#include "gotocelldialog.h"
GoToCellDialog::GoToCellDialog(QWidget *parent): QDialog(parent)
{
setupUi(this); 
QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
QValidator *validator = new QRegExpValidator(regExp, this);
lineEdit->setValidator(validator);
connect(okButton, SIGNAL(clicked()),this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
void GoToCellDialog::on_lineEdit_textChanged()
{
okButton->setEnabled(lineEdit->hasAcceptableInput());
}

感谢。

2 个答案:

答案 0 :(得分:2)

Qt知道如何自动连接根据约定on_ObjectName_SignalName()命名的某些信号和端口。有关示例,请参阅http://doc.qt.nokia.com/latest/designer-using-a-ui-file.html#automatic-connections。 Qt API在http://doc.qt.nokia.com/latest/qobject.html#auto-connection处描述了该功能。

答案 1 :(得分:0)

如果通过IDE将on_lineEdit_textChanged()分配给QLineEdit等组件,则当用户更改组件的内容时,框架本身会调用该方法。

换句话说,它是一个回调函数。

相关问题