I'm getting the following errors when building with QMake:
LNK2019: unresolved external symbol "public: void __cdecl TimerTodo::notify(class TodoBaseTask *)" (?notify@TimerTodo@@QEAAXPEAVTodoBaseTask@@@Z) referenced in function "private: void __cdecl TimerTodo::timerOver(void)" (?timerOver@TimerTodo@@AEAAXXZ)
LNK2019: unresolved external symbol "public: void __cdecl TimerTodo::hasNotified(class TimerTodo *)" (?hasNotified@TimerTodo@@QEAAXPEAV1@@Z) referenced in function "private: void __cdecl TimerTodo::timerOver(void)" (?timerOver@TimerTodo@@AEAAXXZ)
LNK1120: 2 unresolved externals
This is my header:
#ifndef TIMERTODO_H
#define TIMERTODO_H
#include <QTimer>
class TodoBaseTask;
class TimerTodo : public QTimer
{
public:
TimerTodo(TodoBaseTask *timer);
void StartTimer();
private slots:
void timerOver();
signals:
void notify(TodoBaseTask *todo);
void hasNotified(TimerTodo *timer);
private:
TodoBaseTask *m_todo;
};
#endif // TIMERTODO_H
And this is my source:
#include "timertodo.h"
#include "todobasetask.h"
TimerTodo::TimerTodo(TodoBaseTask *todo)
{
m_todo = todo;
connect(this, SIGNAL(timeout()), this, SLOT(timerOver()));
}
void TimerTodo::StartTimer()
{
QDateTime nextNotify = m_todo->getDeadLine().addDays(-1);
this->start(QDateTime::currentDateTime().msecsTo(nextNotify));
}
void TimerTodo::timerOver()
{
emit notify(m_todo);
emit hasNotified(this);
}
How to fix it?
Q_OBJECTmacro in your class declaration and rebuild. - vahancho