Results 1 to 3 of 3

Thread: make error

  1. #1
    Join Date
    Oct 2006
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default make error

    I start to learn qt use the book C++ GUI programming with QT4
    and i type the ch02 's sourcefile
    finddialog.cpp
    Qt Code:
    1. #include <QtGui>
    2. #include "finddialog.h"
    3.  
    4. FindDialog::FindDialog(QWidget *parent) :QDialog(parent)
    5. {
    6. label = new QLabel(tr("Find &what:"));
    7. lineEdit = new QLineEdit;
    8. label->setBuddy(lineEdit);
    9. caseCheckBox = new QCheckBox(tr("Match &case"));
    10. backwardCheckBox = new QCheckBox(tr("Search &backward"));
    11. findButton = new QPushButton(tr("&Find"));
    12. findButton->setDefault(true);
    13. findButton->setEnabled(false);
    14. closeButton = new QPushButton(tr("Close"));
    15. connect(lineEdit, SIGNAL(textChanged(const QString &)),
    16. this, SLOT(enableFindButton(const QString &)));
    17. connect(findButton,SIGNAL(clicked()),
    18. this, SLOT(findClicked()));
    19. connect(closeButton,SIGNAL(clicked()),
    20. this, SLOT(close()));
    21. QHBoxLayout *topLeftLayout = new QHBoxLayout;
    22. topLeftLayout->addWidget(label);
    23. topLeftLayout->addWidget(lineEdit);
    24. QVBoxLayout *leftLayout = new QVBoxLayout;
    25. leftLayout->addLayout(topLeftLayout);
    26. leftLayout->addWidget(caseCheckBox);
    27. leftLayout->addWidget(backwardCheckBox);
    28. QVBoxLayout *rightLayout=new QVBoxLayout;
    29. rightLayout->addWidget(findButton);
    30. rightLayout->addWidget(closeButton);
    31. rightLayout->addStretch();
    32. QHBoxLayout *mainLayout = new QHBoxLayout;
    33. mainLayout->addLayout(leftLayout);
    34. mainLayout->addLayout(rightLayout);
    35. setLayout(mainLayout);
    36. setWindowTitle(tr("Find"));
    37. setFixedHeight(sizeHint().height());
    38. }
    39. void FindDialog::findClicked()
    40. {
    41. QString text = lineEdit->text();
    42. Qt::CaseSensitivity cs=
    43. caseCheckBox->isChecked() ? Qt::CaseSensitive
    44. : Qt::CaseInsensitive;
    45. if (backwardCheckBox->isChecked()) {
    46. emit findPrevious(text,cs);
    47. } else {
    48. emit findNext(text, cs);
    49. }
    50. }
    51. void FindDialog::enableFindButton(const QString &text)
    52. {
    53. findButton->setEnabled(!text.isEmpty());
    54. }_
    To copy to clipboard, switch view to plain text mode 

    **********************************
    finddialog.h
    Qt Code:
    1. #ifndef FINDDIALOG_H
    2. #define FINDDIALOG_H
    3. #include <QDialog>
    4. class QCheckBox;
    5. class QLabel;
    6. class QLineEdit;
    7.  
    8. class FindDialog : public QDialog
    9. {
    10. Q_OBJECT
    11. public:
    12. FindDialog(QWidget *parent = 0);
    13. signals:
    14. void findNext(const QString &str, Qt::CaseSensitivity cs);
    15. void findPrevious(const QString &str, Qt::CaseSensitivity cs);
    16. private slots:
    17. void findClicked();
    18. void enableFindButton(const QString &text);
    19. private:
    20. QLabel *label;
    21. QLineEdit *lineEdit;
    22. QCheckBox *caseCheckBox;
    23. QCheckBox *backwardCheckBox;
    24. QPushButton *findButton;
    25. QPushButton *closeButton;
    26.  
    27. };
    28. #endif
    To copy to clipboard, switch view to plain text mode 

    ***********************************8
    main.cpp

    Qt Code:
    1. #include <QApplication>
    2. #include "finddiaglog.h"
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv)
    6. FindDialog *dialog = new FindDialog;
    7. dialog->show();
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    i use mingw and type
    qmake -project
    qmake
    make

    the output show
    g++ -c -O2 -O2 -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"D:/Qt/4.2.1/include/QtCore" -I"D:/Qt/4.2.1/include/QtCore" -I"D:/Qt/4.2.1/include/QtGui" -I"D:/Qt/4.2.1/include/QtGui" -I"D:/Qt/4.2.1/include" -I"." -I"D:/Qt/4.2.1/include/ActiveQt" -I"release" -I"." -I"d:\Qt\4.2.1\mkspecs\win32-g++" -o release\finddialog.o finddialog.cpp
    finddialog.cpp:54: error: expected constructor, destructor, or type conversion at end of input
    i don't know what's wrong with the code? please help
    Last edited by wysota; 29th October 2006 at 08:56. Reason: missing [code] tags, reformatted to look better

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: make error

    I can only see a few minor misspellings there:

    finddialog.cpp:
    Qt Code:
    1. void FindDialog::enableFindButton(const QString &text)
    2. {
    3. findButton->setEnabled(!text.isEmpty());
    4. }_ // <-- remove the additional underscore
    To copy to clipboard, switch view to plain text mode 

    main.cpp:
    Qt Code:
    1. #include "finddiaglog.h" // <-- typo
    2. ...
    3. QApplication app(argc, argv); // <-- semicolon missing
    To copy to clipboard, switch view to plain text mode 

    PS. Please use [ code ] -tags to make code snippets more readable..
    J-P Nurmi

  3. #3
    Join Date
    Sep 2006
    Posts
    27
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: make error

    I tkink you should also explicitely call "delete" on top-level widgets, else it never gets deallocated:

    Qt Code:
    1. //...
    2. FindDialog *dialog = new FindDialog;
    3. dialog->show();
    4. const int nReturnValue = app.exec();
    5. delete dialog;
    6. return nReturnValue;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 25th August 2006, 00:31
  2. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 13:52
  3. Problems
    By euthymos in forum Installation and Deployment
    Replies: 2
    Last Post: 13th June 2006, 20:11
  4. Fed up with M$ Window$ !!! Why is Tux leaving me alone???
    By fullmetalcoder in forum General Discussion
    Replies: 35
    Last Post: 18th March 2006, 13:57
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 13:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.