开发者

Where does the function call occur?

In the following code from the C++ GUI Programming with Qt 4, where is the call for the on_lineEdit_textchanged() function occuring, as it is not explicitly shown in the code?

#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());
}

开发者_运维知识库Thanks.


Qt knows how to autoconnect certain signals and ports which are named according to the convention on_ObjectName_SignalName(). See http://doc.qt.nokia.com/latest/designer-using-a-ui-file.html#automatic-connections for an example. The Qt API describes that functionality at http://doc.qt.nokia.com/latest/qobject.html#auto-connection .


If the on_lineEdit_textChanged() is assigned, throught the IDE, to a component such as QLineEdit, the method is invoked by the framework itself when the user change the component's content.

In other words, it is a callback function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜