PDA

View Full Version : Q_ARG with C++ reference types



RichardNixon
6th August 2008, 09:02
Hi,

Is it possible to use Q_ARG with reference types? For example:


void foo(QIODevice& obj)
{
QMetaObject::invokeMethod(this, "fooImpl", Q_ARG(QIODevice&, obj));
}

This code does not compile because the template type for QArgument is inferred to be QIODevice&, and the QArgument constructor wants a pointer to this type (something like QIODevice&*). Is there a way around this other than simply not using reference types?

wysota
6th August 2008, 10:11
Q_ARG serializes arguments so using references there might not be possible.