代码如下:
1.pro:
#-------------------------------------------------
#
# Project created by
QtCreator 2012-03-04T17:00:13
#
#-------------------------------------------------
QT += core gui
TARGET = 1
TEMPLATE = app
SOURCES += main.cpp\
gotocelldialog.cpp
HEADERS += gotocelldialog.h
FORMS += gotocelldialog.ui
-------------------------------------
gotocelldialog.h:
#ifndef GOTOCELLDIALOG_H
#define GOTOCELLDIALOG_H
#include <QDialog>
#include <ui_gotocelldialog.h>
namespace Ui {
class GoToCellDialog;
}
class GoToCellDialog : public QDialog, public Ui::GoToCellDialog
{
Q_OBJECT
public:
explicit GoToCellDialog(QWidget *parent = 0);
~GoToCellDialog();
private slots:
void on_lineEdit_textChanged();
private:
Ui::GoToCellDialog *ui;
};
#endif // GOTOCELLDIALOG_H
----------------------------------
gotocelldialog.cpp:
#include <QtGui>
#include "gotocelldialog.h"
#include "ui_gotocelldialog.h"
GoToCellDialog::GoToCellDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::GoToCellDialog)
{
ui->setupUi(this);
}
void GoToCellDialog::on_lineEdit_textChanged()
{
okButton->setEnabled("lineEdit->hasAcceptableInput()");//////////////////////////////////
错误在此行}
GoToCellDialog::~GoToCellDialog()
{
delete ui;
}
----------------------
main.cpp:
#include <QtGui/QApplication>
#include "gotocelldialog.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
GoToCellDialog *dialog = new GoToCellDialog;
dialog->show();
return a.exec();
}
--------------------------
gotocelldialog.ui

---------------------------
错误形式:


能够运行,但是在lineEdit中输入一个字符就意外退出并弹出此
对话框