"Q ++ C++ GUI 프로그래밍"에서 제공되는이 기본 Qt 프로그램이 있습니다. 그러나이 책이 Qt 4.4 용으로 작성된 이후에 다른 지침을 따르면 QLineEdit은 키보드에서 텍스트 입력을 표시하지 않습니다.Qt QDialog 문제 : QLineEdit가 입력을받지 않음
소스 코드는 다음과 같습니다 (moc _ *. cpp 파일은 포함되지 않았습니다). 나의 전복 놀이터에서 다운로드 할 수 있습니다 사본을 통해 코드를 다시 조립하고 전체 프로젝트를 붙여 좋아하지 않는 사람들을 위해 :
http://matthewh.me/PlayGround/branches/Qt4Devel/gotocell/ USER = 게스트 PASSWORD = 손님
#include <QApplication>
#include <QDialog>
#include <iostream>
#include "gotocelldialog.h"
int main(int argc, char *argv[ ])
{
QApplication app(argc, argv);
GoToCellDialog *dialog = new GoToCellDialog;
dialog->show();
dialog->activateWindow();
dialog->lineEdit->activateWindow();
return app.exec();
}
#include <QtGui>
#include <iostream>
#include "gotocelldialog.h"
GoToCellDialog::GoToCellDialog(QWidget *parent)
: QDialog(parent) /* Call Parents Constructor */
{
setupUi(this);
lineEdit->setEchoMode(QLineEdit::Normal);
QRegExp regExp("[A-Z][a-z][1-9][0-9]{0,2}");
lineEdit->setValidator(new QRegExpValidator(regExp, this));
//connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
//connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
void GoToCellDialog::on_lineEdit_textChanged()
{
//okButton->setEnabled(lineEdit->hasAcceptableInput());
}
#ifndef GOTOCELLDIALOG_H
#define GOTOCELLDIALOG_H
#include <QDialog>
#include "ui_gotocelldialog.h"
/* Adapter Class */
class GoToCellDialog : public QDialog, public Ui::GoToCellDialog
{
Q_OBJECT
public:
GoToCellDialog(QWidget *parent = 0);
private slots:
void on_lineEdit_textChanged();
};
#endif
/********************************************************************************
** Form generated from reading UI file 'gotocelldialog.ui'
**
** Created: Sat Aug 20 23:05:28 2011
** by: Qt User Interface Compiler version 4.7.3
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_GOTOCELLDIALOG_H
#define UI_GOTOCELLDIALOG_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QHeaderView>
#include <QtGui/QLineEdit>
QT_BEGIN_NAMESPACE
class Ui_GoToCellDialog
{
public:
QLineEdit *lineEdit;
void setupUi(QDialog *GoToCellDialog)
{
if (GoToCellDialog->objectName().isEmpty())
GoToCellDialog->setObjectName(QString::fromUtf8("GoToCellDialog"));
GoToCellDialog->resize(286, 110);
lineEdit = new QLineEdit(GoToCellDialog);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
lineEdit->setGeometry(QRect(92, 23, 165, 24));
retranslateUi(GoToCellDialog);
QMetaObject::connectSlotsByName(GoToCellDialog);
} // setupUi
void retranslateUi(QDialog *GoToCellDialog)
{
GoToCellDialog->setWindowTitle(QApplication::translate("GoToCellDialog", "Go to Cell", 0, QApplication::UnicodeUTF8));
lineEdit->setPlaceholderText(QString());
} // retranslateUi
};
namespace Ui {
class GoToCellDialog: public Ui_GoToCellDialog {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_GOTOCELLDIALOG_H