Results 1 to 13 of 13

Thread: dummy question(Error)

  1. #1
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default dummy question(Error)

    Why does this error happen? I am sure that there is such a file in the directory! what is the problem?


    [HTML]1>------ Build started: Project: finddialog, Configuration: Debug Win32 ------
    1>Compiling...
    1>FindDialog.cpp
    1>.\FindDialog.cpp(2) : fatal error C1083: Cannot open include file: 'FindDialog': No such file or directory
    1>main.cpp
    1>.\main.cpp(2) : fatal error C1083: Cannot open include file: 'FindDialog': No such file or directory
    1>Generating Code...
    1>Build log was saved at "file://c:\******************My Documents\Visual Studio 2005\QT4\finddialog\finddialog\Debug\BuildLog.htm"
    1>finddialog - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/HTML]

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dummy question(Error)

    In project properties, in the adtional include directories, add a ".\" entry.
    This means it will look for user headers in the current directory too.

    EDIT: This option is the first one in C/C++ / General.

    Regards
    Last edited by marcel; 19th July 2007 at 21:29.

  3. #3
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Red face Re: dummy question(Error)

    Quote Originally Posted by marcel View Post
    In project properties, in the additional include directories, add a ".\" entry.
    This means it will look for user headers in the current directory too.

    EDIT: This option is the first one in C/C++ / General.

    Regards
    Hi Marcel,

    I just added what you said. But the same thing happened!

    [HTML]
    1>------ Build started: Project: FindDialog, Configuration: Debug Win32 ------
    1>Compiling...
    1>main.cpp
    1>.\main.cpp(2) : fatal error C1083: Cannot open include file: 'FindDialog': No such file or directory
    1>FindDialog.cpp
    1>.\FindDialog.cpp(2) : fatal error C1083: Cannot open include file: 'FindDialog': No such file or directory
    1>Generating Code...
    1>Build log was saved at "file://c:\Documents and Settings\********\My Documents\Visual Studio 2005\QT4\finddialog\finddialog\Debug\BuildLog.htm"
    1>FindDialog - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/HTML]

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dummy question(Error)

    Could you post the include section, from the cpp and also from the header?
    Why isn't there a ".h" appended to the header name?
    Is that what the file is being called? Just "FindDialog"? Not "FindDialog.h"?

    Regards

  5. #5
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Red face Re: dummy question(Error)

    Quote Originally Posted by marcel View Post
    Could you post the include section, from the cpp and also from the header?
    Why isn't there a ".h" appended to the header name?
    Is that what the file is being called? Just "FindDialog"? Not "FindDialog.h"?

    Regards
    Hi again,

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

    Header:

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

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dummy question(Error)

    But instead of
    Qt Code:
    1. #include "FindDialog"
    To copy to clipboard, switch view to plain text mode 
    you should have:
    Qt Code:
    1. #include "FindDialog[B].h[/B]"
    To copy to clipboard, switch view to plain text mode 
    It is that simple.
    You can even see in the solution explorer that the file is called FindDialog.h.

    Do this modification and it will work.

    Regards

  7. The following user says thank you to marcel for this useful post:

    Masih (19th July 2007)

  8. #7
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: dummy question(Error)

    Quote Originally Posted by marcel View Post
    But instead of
    Qt Code:
    1. #include "FindDialog"
    To copy to clipboard, switch view to plain text mode 
    you should have:
    Qt Code:
    1. #include "FindDialog[B].h[/B]"
    To copy to clipboard, switch view to plain text mode 
    It is that simple.
    You can even see in the solution explorer that the file is called FindDialog.h.

    Do this modification and it will work.

    Regards
    Well! That's right! I actually did it before and when I saw that I got 46 errors then I thought that is not the solution! But yes! Actually this time it sees the ".h" and ".cpp" file but returns a massive amount of errors!

    I have to get used to this debugging thing! I am sending the Long Error-list also here.

    1>------ Build started: Project: FindDialog, Configuration: Debug Win32 ------
    1>Compiling...
    1>main.cpp
    1>FindDialog.cpp
    1>.\FindDialog.cpp(7) : error C2514: 'QLabel' : class has no constructors
    1> c:\documents and settings\aebio\my documents\visual studio 2005\qt4\finddialog\finddialog\FindDialog.h(6) : see declaration of 'QLabel'
    1>.\FindDialog.cpp(8) : error C2512: 'QLineEdit' : no appropriate default constructor available
    1>.\FindDialog.cpp(9) : error C2027: use of undefined type 'QLabel'
    1> c:\documents and settings\aebio\my documents\visual studio 2005\qt4\finddialog\finddialog\FindDialog.h(6) : see declaration of 'QLabel'
    1>.\FindDialog.cpp(9) : error C2227: left of '->setBuddy' must point to class/struct/union/generic type
    1>.\FindDialog.cpp(10) : error C2514: 'QCheckBox' : class has no constructors
    1> c:\documents and settings\aebio\my documents\visual studio 2005\qt4\finddialog\finddialog\FindDialog.h(5) : see declaration of 'QCheckBox'
    1>.\FindDialog.cpp(11) : error C2514: 'QCheckBox' : class has no constructors
    1> c:\documents and settings\aebio\my documents\visual studio 2005\qt4\finddialog\finddialog\FindDialog.h(5) : see declaration of 'QCheckBox'
    1>.\FindDialog.cpp(12) : error C2514: 'QPushButton' : class has no constructors
    1> c:\qt\4.2.0-vs2005\include\qtgui\../../src/gui/dialogs/qdialog.h(31) : see declaration of 'QPushButton'
    1>.\FindDialog.cpp(13) : error C2027: use of undefined type 'QPushButton'
    1> c:\qt\4.2.0-vs2005\include\qtgui\../../src/gui/dialogs/qdialog.h(31) : see declaration of 'QPushButton'
    1>.\FindDialog.cpp(13) : error C2227: left of '->setDefault' must point to class/struct/union/generic type
    1>.\FindDialog.cpp(14) : error C2027: use of undefined type 'QPushButton'
    1> c:\qt\4.2.0-vs2005\include\qtgui\../../src/gui/dialogs/qdialog.h(31) : see declaration of 'QPushButton'
    1>.\FindDialog.cpp(14) : error C2227: left of '->setEnabled' must point to class/struct/union/generic type
    1>.\FindDialog.cpp(15) : error C2514: 'QPushButton' : class has no constructors
    1> c:\qt\4.2.0-vs2005\include\qtgui\../../src/gui/dialogs/qdialog.h(31) : see declaration of 'QPushButton'
    1>.\FindDialog.cpp(17) : error C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 1 from 'QLineEdit *' to 'const QObject *'
    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>.\FindDialog.cpp(19) : error C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 1 from 'QPushButton *' to 'const QObject *'
    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>.\FindDialog.cpp(21) : error C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 1 from 'QPushButton *' to 'const QObject *'
    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>.\FindDialog.cpp(22) : error C2065: 'QHBoxLayout' : undeclared identifier
    1>.\FindDialog.cpp(22) : error C2065: 'topLeftLayout' : undeclared identifier
    1>.\FindDialog.cpp(22) : error C2061: syntax error : identifier 'QHBoxLayout'
    1>.\FindDialog.cpp(23) : error C2227: left of '->addWidget' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(24) : error C2227: left of '->addWidget' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(25) : error C2065: 'QVBoxLayout' : undeclared identifier
    1>.\FindDialog.cpp(25) : error C2065: 'leftLayout' : undeclared identifier
    1>.\FindDialog.cpp(25) : error C2061: syntax error : identifier 'QVBoxLayout'
    1>.\FindDialog.cpp(26) : error C2227: left of '->addLayout' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(27) : error C2227: left of '->addWidget' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(28) : error C2227: left of '->addWidegt' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(29) : error C2065: 'rightLayout' : undeclared identifier
    1>.\FindDialog.cpp(29) : error C2061: syntax error : identifier 'QVBoxLayout'
    1>.\FindDialog.cpp(30) : error C2227: left of '->addWidget' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(31) : error C2227: left of '->addWidget' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(32) : error C2227: left of '->addStretch' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(33) : error C2065: 'mainLayout' : undeclared identifier
    1>.\FindDialog.cpp(33) : error C2061: syntax error : identifier 'QHBoxLayout'
    1>.\FindDialog.cpp(34) : error C2227: left of '->addLayout' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(35) : error C2227: left of '->addLayout' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(41) : error C2653: 'FindDFialog' : is not a class or namespace name
    1>.\FindDialog.cpp(43) : error C2065: 'lineEdit' : undeclared identifier
    1>.\FindDialog.cpp(43) : error C2227: left of '->text' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(45) : error C2065: 'caseCheckBox' : undeclared identifier
    1>.\FindDialog.cpp(45) : error C2227: left of '->isChecked' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(47) : error C2065: 'backwardCheckBox' : undeclared identifier
    1>.\FindDialog.cpp(47) : error C2227: left of '->isChecked' must point to class/struct/union/generic type
    1> type is ''unknown-type''
    1>.\FindDialog.cpp(48) : error C3861: 'findPrevious': identifier not found
    1>.\FindDialog.cpp(50) : error C3861: 'findNext': identifier not found
    1>.\FindDialog.cpp(55) : error C2027: use of undefined type 'QPushButton'
    1> c:\qt\4.2.0-vs2005\include\qtgui\../../src/gui/dialogs/qdialog.h(31) : see declaration of 'QPushButton'
    1>.\FindDialog.cpp(55) : error C2227: left of '->setEnabled' must point to class/struct/union/generic type
    1>Generating Code...
    1>Build log was saved at "file://c:\Documents and Settings\*******\My Documents\Visual Studio 2005\QT4\finddialog\finddialog\Debug\BuildLog.htm"
    1>FindDialog - 46 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Last edited by jacek; 19th July 2007 at 22:16. Reason: changed [html] to [quote]

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dummy question(Error)

    Add missing #include directives to FindDialog.cpp and the errors should go away.

  10. The following user says thank you to jacek for this useful post:

    Masih (19th July 2007)

  11. #9
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dummy question(Error)

    Those are because you did not included the necessary files in the cpp file.
    For example QLabel, QPushButton, etc...

    You should include all the headers for the classes that you forward declared in FindDialog.h.

    Regards
    Last edited by marcel; 19th July 2007 at 22:27.

  12. The following user says thank you to marcel for this useful post:

    Masih (19th July 2007)

  13. #10
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: dummy question(Error)

    Quote Originally Posted by marcel View Post
    Those are because you did not included the necessary files in the cpp file.
    For example QLabel, QPushButton, etc...

    You should include all the headers for the classes that you forward declared in FindDialog.h.

    Regards

    Yeah! I included those mentioned classes. and seems that it would work! But still a question! I have this error right now!

    1>------ Build started: Project: FindDialog, Configuration: Debug Win32 ------
    1>Compiling...
    1>FindDialog.cpp
    1>Compiling...
    1>moc_finddialog.cpp
    1>Linking...
    1>FindDialog.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall FindDialog::~FindDialog(void)" (??1FindDialog@@UAE@XZ) referenced in function "public: virtual void * __thiscall FindDialog::`scalar deleting destructor'(unsigned int)" (??_GFindDialog@@UAEPAXI@Z)
    1>C:\Documents and Settings\*****\My Documents\Visual Studio 2005\QT4\finddialog\Debug\FindDialog.exe : fatal error LNK1120: 1 unresolved externals
    1>Build log was saved at "file://c:\Documents and Settings\*****\My Documents\Visual Studio 2005\QT4\finddialog\finddialog\Debug\BuildLog.htm"
    1>FindDialog - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    any idea?

    regards,
    Masih
    Last edited by jacek; 20th July 2007 at 00:16. Reason: changed [html] to [quote]

  14. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dummy question(Error)

    You have declared a destructor, but you didn't implement it. Either remove the declaration or add the implementation.

  15. The following user says thank you to jacek for this useful post:

    Masih (20th July 2007)

  16. #12
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: dummy question(Error)

    Quote Originally Posted by jacek View Post
    You have declared a destructor, but you didn't implement it. Either remove the declaration or add the implementation.
    Yes! It is working now!!
    Is it better to use destructor in Qt or let it the compiler do it?

  17. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dummy question(Error)

    Quote Originally Posted by Masih View Post
    Is it better to use destructor in Qt or let it the compiler do it?
    It depends how you implement your class. Qt deletes all child QObjects, when their parent is destroyed, so usually you don't need a destructor.

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.