回各位,本人自己检查了N编,确实没发现少分号之类的错误。崩溃中!
现将全部文件贴出,请各位帮忙看看。谢谢!
1.h:
#ifndef _1_H
#define _1_H
#include<QDialog>
class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;
class FindDialog: public QDialog
{
Q_OBJECT
public:
FindDialog(QWidget *parent=0);
signals:
void findNext(const QString &str,Qt::CaseSensitivity CS);
void findPrevious(const QString &str,Qt::CaseSensitivity CS);
private slots:
void findClicked();
void enableFindButton(const QString &text);
private:
QLabel *label;
QLineEdit *lineedit;
QCheckBox *casecheckbox;
QCheckBox *backwardcheckbox;
QPushButton *findbutton;
QPushButton *closebutton;
}
#endif
1.cpp:
#include<QtGui>
#include "1.h"
FindDialog::FindDialog(QWidget *parent)
: QDialog(parent)
{
lable=new QLable(tr("Find &What"));
lineedit=new LineEdit();
label->setBuddy (lineedit);
casecheckbox=new CheckBox(tr(Match &case));
backwardCheckbox = new QCheckBox(tr("Search &backward"));
findbutton=new QPushButton(tr(&Find));
findbutton->setDefault(true);
findbutton->setEnabled(false);
closebutton = new QPushButton(tr("Close"));
QObject::connect(lineedit,SIGNAL(textChanged(const Qstring &)),this,
SLOT(enableFindButton(const Qtring &)));
QObject::connect(findbutton,SIGNAL(clicked()),this,
SLOT(findClicked()));
connect (closeButton, SIGNAL(clicked()),
this, SLOT(close ()));
QHBoxLayout *lefttoplayout=new QHBoxLayout;
lefttoplayout->addWidget(label);
lefttoplayout->addWidget(lineedit);
QVBoxLayout *leftlayout=new QVBoxLayout;
leftlayout->addLayout(lefttoplayout);
leftlayout->addWidget(casecheckbox);
leftlayot->addWidget(backwardcheckbox);
QHBoxLayout *rightLayout=new QHBoxLayout;
rightlayout->addWidget(findbutton);
rightlayout->addWidget(closebutton);
rightlayout->addStretch();
QHBoxLayout *mainlayout=new QHBoxLayout;
mainlayout->addLayout(leftlayout);
mainlayout->addLayout(rightlayout);
this.setLayout(mainlayout);
this.setWindowTitle(tr("Find"));
this.setFixedHeight(sizeHint().height());
}
void FindDialog::findClicked()
{
QString text = lineEdit->text();
Qt::CaseSensitivity cs =
caseCheckBox->isChecked()?Qt::CaseSensitive
: Qt::CaseInsensive;
if (backwardCheckBox->isChecked())
{
emit findPrevious(text, cs);
}
Else
{
emit findNext(text, cs);
}
}
void FindDialog::enableFindButton(const QString &text)
{
findbutton->setEnabled(!text.isEmpty());
}
main.cpp:
#include<QApplication>
#include "1.cpp"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
FindDialog *dialog = new FindDialog;
dialog->show();
return app.exec();
}