I get tons of erros for ant make program run C++ gui programming on page 31. I entered the whole program perfectly .
Here it is
finddialog.h
001 #ifndef FINDDIALOG_H
002 #define FINDDIALOG_H
003 #include <QDialog>
004 class QCheckBox;
005 class QLabel;
006 class QLineEdit;
007 class QPushButton;
008 class FindDialog : public QDialog
009 {
010 Q_OBJECT
011 public:
012 FindDialog(QWidget *parent = 0);
013 signals:
014 void findNext(const QString &str, Qt::CaseSensitivity cs);
015 void findPrevious(const QString &str, Qt::CaseSensitivity cs);
016 private slots:
017 void findClicked();
018 void enableFindButton(const QString &text);
019 private:
020 QLabel *label;
021 QLineEdit *lineEdit;
022 QCheckBox *caseCheckBox;
023 QCheckBox *backwardCheckBox;
024 QPushButton *findButton;
025 QPushButton *closeButton;
026 };
027 #endif
finddialog.cpp
001 #include <QtGui>
002 #include "finddialog.h"
003 FindDialog::FindDialog(QWidget *parent)
004 : QDialog(parent)
005 {
006 label = new QLabel(tr("Find &what:"));
007 lineEdit = new QLineEdit;
008 label->setBuddy(lineEdit);
009 caseCheckBox = new QCheckBox(tr("Match &case"));
010 backwardCheckBox = new QCheckBox(tr("Search &backward"));
011 findButton = new QPushButton(tr("&Find"));
012 findButton->setDefault(true);
013 findButton->setEnabled(false);
014 closeButton = new QPushButton(tr("Close"));
015 connect(lineEdit, SIGNAL(textChanged(const QString &)),
016 this, SLOT(enableFindButton(const QString &)));
017 connect(findButton, SIGNAL(clicked()),
018 this, SLOT(findClicked()));
019 connect(closeButton, SIGNAL(clicked()),
020 this, SLOT(close()));
021 QHBoxLayout *topLeftLayout = new QHBoxLayout;
022 topLeftLayout->addWidget(label);
023 topLeftLayout->addWidget(lineEdit);
024 QVBoxLayout *leftLayout = new QVBoxLayout;
025 leftLayout->addLayout(topLeftLayout);
026 leftLayout->addWidget(caseCheckBox);
027 leftLayout->addWidget(backwardCheckBox);
028 QVBoxLayout *rightLayout = new QVBoxLayout;
029 rightLayout->addWidget(findButton);
030 rightLayout->addWidget(closeButton);
031 rightLayout->addStretch();
032 QHBoxLayout *mainLayout = new QHBoxLayout;
033 mainLayout->addLayout(leftLayout);
034 mainLayout->addLayout(rightLayout);
035 setLayout(mainLayout);
036 setWindowTitle(tr("Find"));
037 setFixedHeight(sizeHint().height());
038 }
039 void FindDialog::findClicked()
040 {
041 QString text = lineEdit->text();
042 Qt::CaseSensitivity cs =
043 caseCheckBox->isChecked() ? Qt::CaseSensitive
044 : Qt::CaseInsensitive;
045 if (backwardCheckBox->isChecked()) {
046 emit findPrevious(text, cs);
047 } else {
048 emit findNext(text, cs);
049 }
050 }
051 void FindDialog::enableFindButton(const QString &text)
052 {
053 findButton->setEnabled(!text.isEmpty());
054 }
main.cpp
001 #include <QApplication>
002 #include "finddialog.h"
003 int main(int argc, char *argv[])
004 {
005 QApplication app(argc, argv);
006 FindDialog *dialog = new FindDialog;
007 dialog->show();
008 return app.exec();
009 }
One of the errors Isee is the build choking on #include <QtGui> I finf this happening in some of the demo programs too.
I don't know how to fix this problem HELP !![]()
Bookmarks