[Qt-interest] QCoreApplication derived class' slots not being called

Andrea Franceschini therealmorpheu5 at gmail.com
Wed Jan 21 16:18:52 CET 2009


Hi all, this issue is really driving me mad so if anyone of you could
help me sort it out, I'll be infinitely grateful. I have a class that
derives from QObject and emits some signals (I'l omit non-relevant
parts):

namespace Glyphs {
class TuioProxy : public QObject {
	Q_OBJECT

public:
	// blah blah...

signals:
	void tonalizerIn(TuioObject* tobj);
	void tonalizerUpdate(TuioObject* tobj);
	void tonalizerOut(TuioObject* tobj);

	void fingerDown(TuioCursor* tcur);
	void fingerUpdate(TuioCursor* tcur);
	void fingerUp(TuioCursor* tcur);

private:
	// blah blah...
};
}

which constructor is

Glyphs::TuioProxy::TuioProxy(int port, int tonalizerFiducial) : QObject() {
	// blah blah ...
}

with all the emissions in the usual form emit(tonalizerIn(tobj)). Then
I have a class that derives from QCoreApplication and has some slots:

namespace Glyphs {
class Application : public QCoreApplication {
	Q_OBJECT

public:
	// blah blah ...
	// Ok, this was private, I'll fix it later...
	Glyphs::TuioProxy* _tuioProxy;

public slots:
	void tonalizerIn(TuioObject* tobj);
	void tonalizerUpdate(TuioObject* tobj);
	void tonalizerOut(TuioObject* tobj);

	void fingerDown(TuioCursor* tcur);
	void fingerUpdate(TuioCursor* tcur);
	void fingerUp(TuioCursor* tcur);

private:
	// blah blah ...
};
}

which constructor is

Glyphs::Application::Application(int& argc, char** argv) :
QCoreApplication(argc, argv) {
	// blah blah ...

	connect(_tuioProxy, SIGNAL(tonalizerIn(TuioObject*)), this,
SLOT(tonalizerIn(TuioObject*)));
	connect(_tuioProxy, SIGNAL(tonalizerUpdate(TuioObject*)), this,
SLOT(tonalizerUpdate(TuioObject*)));
	connect(_tuioProxy, SIGNAL(tonalizerOut(TuioObject*)), this,
SLOT(tonalizerOut(TuioObject*)));

	connect(_tuioProxy, SIGNAL(fingerDown(TuioCursor*)), this,
SLOT(fingerDown(TuioCursor*)));
	connect(_tuioProxy, SIGNAL(fingerUpdate(TuioCursor*)), this,
SLOT(fingerUpdate(TuioCursor*)));
	connect(_tuioProxy, SIGNAL(fingerUp(TuioCursor*)), this,
SLOT(fingerUp(TuioCursor*)));
}

and don't mention the fact that signals and slots are named the same:
I already tried changing them with no benefit. Now the problem is that

a) if I omit Q_OBJECT from the declaration of Application, then the
connect phase results in something like no such slot
QCoreApplication::tonalizerIn(TuioObject*) which is -- I guess --
correct, since QCoreApplication is supposed to not have those slots;
b) if I put Q_OBJECT (then clean the old build so moc is happier) then
the connect phase remains silent (is it going ok?) but no slot is
being called, albeit signals are correctly emitted (I also checked
manually by modifying the mocs...).

Now my guesses are:
1) I'm missing something completely evident;
2) classes that derive from QCoreApplication have strange behaviour
and don't support custom slots (what?!).

I'm pretty stuck with this so the first that succeeds in helping me
gets a free virtual hug :)
Thanks.



More information about the Qt-interest-old mailing list