PDA

View Full Version : dummy question(Error)



Masih
19th July 2007, 20:20
Why does this error happen? I am sure that there is such a file in the directory! what is the problem?



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 ==========:crying:

marcel
19th July 2007, 20:24
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

Masih
19th July 2007, 20:45
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!
:o


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 ==========

marcel
19th July 2007, 20:47
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

Masih
19th July 2007, 20:59
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

#include <QtGui/QApplication>
#include "FindDialog"

FindDialog::FindDialog(QWidget *parent)
:QDialog(parent)
{
label = new QLabel(tr("Find &what:"));
lineEdit= new QLineEdit;
label->setBuddy(lineEdit);
caseCheckBox = new QCheckBox(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"));
connect(lineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(enableFindButton(const QString &)));
connect(findButton, SIGNAL(clicked()),
this, SLOT(findClicked()));
connect(closeButton, SIGNAL(clicked()),
this, SLOT(close()));
QHBoxLayout* topLeftLayout = new QHBoxLayout;
topLeftLayout->addWidget(label);
topLeftLayout->addWidget(lineEdit);
QVBoxLayout* leftLayout = new QVBoxLayout;
leftLayout->addLayout(topLeftLayout);
leftLayout->addWidget(caseCheckBox);
leftLayout->addWidegt(backwardCheckBox);
QVBoxLayout* rightLayout = new QVBoxLayout;
rightLayout->addWidget(findButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch();
QHBoxLayout* mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);
setWindowTitle(tr("Find"));
setFixedHeight(sizeHint().height());
}

void FindDFialog::findClicked()
{
QString text =lineEdit->text();
Qt::CaseSensitivity cs =
caseCheckBox->isChecked() ? Qt::CaseSensitive
: Qt::CaseInsensitive;
if (backwardCheckBox->isChecked()) {
emit findPrevious(text, cs);
} else {
emit findNext(text, cs);
}
}
void FindDialog::enableFindButton(const QString &text)
{
findButton->setEnabled(!text.isEmpty());
}

Header:


#ifndef FINDDIALOG_H
#define FINDDIALOG_H

#include <QDialog>
class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;


class FindDialog : public QDialog
{
Q_OBJECT

public:
FindDialog(QWidget *parent = 0);
~FindDialog();
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

marcel
19th July 2007, 21:02
But instead of


#include "FindDialog"

you should have:


#include "FindDialog.h"

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

Masih
19th July 2007, 21:14
But instead of


#include "FindDialog"

you should have:


#include "FindDialog.h"

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 ==========

jacek
19th July 2007, 21:16
Add missing #include directives to FindDialog.cpp and the errors should go away.

marcel
19th July 2007, 21:18
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

Masih
19th July 2007, 22:22
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

jacek
19th July 2007, 23:18
You have declared a destructor, but you didn't implement it. Either remove the declaration or add the implementation.

Masih
19th July 2007, 23:23
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?

jacek
19th July 2007, 23:38
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.