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
Re: dummy question(Error)
Quote:
Originally Posted by
marcel
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
[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]
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
1 Attachment(s)
Re: dummy question(Error)
Quote:
Originally Posted by
marcel
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
Code:
#include <QtGui/QApplication>
#include "FindDialog"
FindDialog
::FindDialog(QWidget *parent
){
label
= new QLabel(tr
("Find &what:"));
label->setBuddy(lineEdit);
caseCheckBox
= new QCheckBox(tr
("Match &case"));
backwardCheckBox
= new QCheckBox(tr
("Search &backward"));
findButton->setDefault(true);
findButton->setEnabled(false);
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()));
topLeftLayout->addWidget(label);
topLeftLayout->addWidget(lineEdit);
leftLayout->addLayout(topLeftLayout);
leftLayout->addWidget(caseCheckBox);
leftLayout->addWidegt(backwardCheckBox);
rightLayout->addWidget(findButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch();
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);
setWindowTitle(tr("Find"));
setFixedHeight(sizeHint().height());
}
void FindDFialog::findClicked()
{
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:
Code:
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include <QDialog>
{
Q_OBJECT
public:
~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:
};
#endif
Re: dummy question(Error)
But instead of
Code:
#include "FindDialog"
you should have:
Code:
#include "FindDialog[B].h[/B]"
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
Re: dummy question(Error)
Quote:
Originally Posted by
marcel
But instead of
Code:
#include "FindDialog"
you should have:
Code:
#include "FindDialog[B].h[/B]"
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.
Quote:
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 ==========
Re: dummy question(Error)
Add missing #include directives to FindDialog.cpp and the errors should go away.
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
Re: dummy question(Error)
Quote:
Originally Posted by
marcel
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!
Quote:
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
Re: dummy question(Error)
You have declared a destructor, but you didn't implement it. Either remove the declaration or add the implementation.
Re: dummy question(Error)
Quote:
Originally Posted by
jacek
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?
Re: dummy question(Error)
Quote:
Originally Posted by
Masih
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.