Qt and variadic functions
Posted
by
Noah Roberts
on Stack Overflow
See other posts from Stack Overflow
or by Noah Roberts
Published on 2010-12-27T21:47:33Z
Indexed on
2010/12/27
21:54 UTC
Read the original article
Hit count: 301
OK, before lecturing me on the use of C-style variadic functions in C++...everything else has turned out to require nothing short of rewriting the Qt MOC.
What I'd like to know is whether or not you can have a "slot" in a Qt object that takes an arbitrary amount/type of arguments. The thing is that I really want to be able to generate Qt objects that have slots of an arbitrary signature. Since the MOC is incompatible with standard preprocessing and with templates, it's not possible to do so with either direct approach. I just came up with another idea:
struct funky_base : QObject
{
Q_OBJECT
funky_base(QObject * o = 0);
public slots:
virtual void the_slot(...) = 0;
};
If this is possible then, because you can make a template that is a subclass of a QObject derived object so long as you don't declare new Qt stuff in it, I should be able to implement a derived templated type that takes the ...
stuff and turns it into the appropriate, expected types.
If it is, how would I connect to it? Would this work?
connect(x, SIGNAL(someSignal(int)), y, SLOT(the_slot(...)));
If nobody's tried anything this insane and doesn't know off hand, yes I'll eventually try it myself...but I am hoping someone already has existing knowledge I can tap before possibly wasting my time on it.
© Stack Overflow or respective owner