[Solved] error LNK2001: unresolved external symbol
-
wrote on 4 Apr 2014, 13:39 last edited by JohanSolo
Did you put the Q_OBJECT macro at the beginning of your class declaration? E.g:
class errorMsg : [...] { Q_OBJECT
-
wrote on 4 Apr 2014, 13:46 last edited by
Yes I did
-
wrote on 4 Apr 2014, 13:49 last edited by
What does you errorMsg class declaration look like?
-
wrote on 4 Apr 2014, 13:57 last edited by
@#ifndef ERRORMSG_H
#define ERRORMSG_Hclass errorMsg : public QObject
{
Q_OBJECTpublic:
errorMsg();
~errorMsg();
void writeErrorMsg(QString msg, int value);};
#endif //ERRORMSG_H@
-
wrote on 4 Apr 2014, 14:13 last edited by JohanSolo
Apart from the
-errorMsg();
which I assume is a typo, this looks almost OK. You seem to be missing the
#include <QtCore/QObject>
directive.
-
wrote on 4 Apr 2014, 14:21 last edited by
The "~errorMsg();" is the destructor, but it is not so usefull.
I added your include line but it didn't change anything.
My includes are
@#include <QString>
#include <QFile>
#include <QTextStream>
#include <iostream>
#include <QDateTime>
#include <QLabel>
#include <QTextEdit>
#include <QtCore/QObject>
#include "mainform.h"@ -
wrote on 4 Apr 2014, 14:30 last edited by
[quote author="bern69" date="1396621287"]The "~errorMsg();" is the destructor, but it is not so usefull.
[/quote]
Obviously, but the "-" should read as a "~"...Indeed the include I told you to add is not needed since many widgets are already included.
I guess you've already tried to rerun qmake and it didn't change a thing.
Could you provide your (complete) .pro file?
Edit: is it only me who sees the tilda as an hyphen?
-
wrote on 4 Apr 2014, 14:30 last edited by
Why would you like to build your errorMsg with Q_OBJECT if you don't declare any signals/slots inside it nor use other Qt's meta-object system services?
-
wrote on 4 Apr 2014, 14:42 last edited by
I removed Q_OBJECT from the class and it works now! Thank you very much! I inserted it because I will program some signals and slots later. If I understand, I have to keep it as commentary until the first slot is inserted?
-
wrote on 4 Apr 2014, 14:54 last edited by
Yes. I don't understand why moc doesn't generate an empty .moc file and some warnings in such case, but it's how it works.
13/13