hmmm.... I'm making things worse it seems
I have 4 files for a test app:
sender.h:
#include <QApplication>
public :
void pokeMe() {emit sendData();}
signals :
void sendData() {}
};
#include <QApplication>
class Sender : public QObject {
public :
Sender(QObject *parent =0) : QObject(parent) {}
void pokeMe() {emit sendData();}
signals :
void sendData() {}
};
To copy to clipboard, switch view to plain text mode
genericservice.h
#ifndef GS_H
#define GS_H
#include <QApplication>
#include <QDebug>
#include "sender.h"
namespace A {
class GenericService
: public QObject { public :
void sendQuery();
protected slots:
void receiveData();
private :
Sender *m_sender;
};
}
#endif
#ifndef GS_H
#define GS_H
#include <QApplication>
#include <QDebug>
#include "sender.h"
namespace A {
class GenericService : public QObject {
public :
GenericService(QObject *parent=0);
void sendQuery();
protected slots:
void receiveData();
private :
Sender *m_sender;
};
}
#endif
To copy to clipboard, switch view to plain text mode
genericservice.cpp
#include "genericservice.h"
using namespace A;
{
m_sender = new Sender(this);
}
void GenericService::sendQuery()
{
connect(m_sender, SIGNAL(sendData()), this, SLOT(receiveData()));
m_sender->pokeMe();
}
void GenericService::receiveData()
{
}
#include "genericservice.h"
using namespace A;
GenericService::GenericService (QObject *parent) : QObject(parent)
{
m_sender = new Sender(this);
}
void GenericService::sendQuery()
{
connect(m_sender, SIGNAL(sendData()), this, SLOT(receiveData()));
m_sender->pokeMe();
}
void GenericService::receiveData()
{
QDebug(new QString("yo"));
}
To copy to clipboard, switch view to plain text mode
and main.cpp
#include <QApplication>
#include "genericservice.cpp"
int main(int argc, char *argv[])
{
GenericService *gen = new GenericService();
gen->sendQuery();
return app.exec();
}
#include <QApplication>
#include "genericservice.cpp"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
GenericService *gen = new GenericService();
gen->sendQuery();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
and now when I build and execute I get:
Object::connect: No such signal QObject::sendData() in genericservice.cpp:13
i.e. the signal from a non-namespaced class is not not being recognized in the namespaced one. I didn't even get around to the derived classes in different namespaces! Could really use some help on this!
Bookmarks