This is driving me insane....it was working earlier, but not it doesn't work. I have defined Q_SLOTS and Q_SIGNALS, and I was trying to connect them. It was working to an extent...and then all of a sudden everything stopped working, and now I am getting errors. My code is the following:
ControllerLogic.h
#ifndef CONTROLLERLOGIC_H
#define CONTROLLERLOGIC_H
#include "initdataaccess.h"
#include "mainframe.h"
#include <QtGui>
#include "initializationdatastructure.h"
/** This is a controller class; refering to the model-view-controller
* architecture.
*/
class ControllerLogic : public QObject
{
Q_OBJECT
public:
ControllerLogic(InitDataAccess *initDataAccess, MainFrame *mainFrame);
Q_SIGNALS:
void Signal();
private:
void setMainFrame(MainFrame mainFrame);
public Q_SLOTS:
void receive();
};
#endif // CONTROLLERLOGIC_H
ControllerLogic.cpp
#include "controllerlogic.h"
#include "licensedataaccess.h"
#include <qobjectdefs.h>
// obsolete...may be used later
ControllerLogic::ControllerLogic(InitDataAccess *initDataAccess, MainFrame *mainFrame)
{
connect(this, SIGNAL(signal()), mainFrame, SLOT(PrintTestSlot()));
}
void ControllerLogic::receive(){
qDebug()<<"RECEIVE";
}
void ControllerLogic::Signal(){
qDebug()<<"SIGNAL";
}
ERROR
moc_controllerlogic.obj:-1: error: LNK2005: "protected: void __thiscall ControllerLogic::Signal(void)" (?Signal@ControllerLogic@@IAEXXZ) already defined in controllerlogic.obj
release\TSLSuite.exe:-1: error: LNK1169: one or more multiply defined symbols found
I also tried to define the signal as follows:
public:
Q_SIGNAL void Signal();
but I get the same error.
What is going on? Please Help!
Thanks!
The problem is that you're trying to define a function called Signal()
Qt generates the body of the "signal" functions for you, and if you try to create your own definition, you will get the error that you're describing.
(As a side note, your connect statement appears to be broken s/signal/Signal/
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With