added a comment - - edited
Your are right. My description wasn't very good.
If I want to invoke a method
void Method(QString arg1, int arg2);
very often I invoke it using typed arguments
QString s = "1";
int x = 2;
invokeMethod(obj, "Method", Q_ARG(QString, s), Q_ARG(int, x));
This is useful if the arguments are passed as above. However if you are using e.g. a generic communication (IPC, RPC), you are getting a list containing QVariants:
QByteArray methodName; // Contains the method name, passed by communication,
QVariantList arguments; // Contains two variants, passed by communication. First should be QString, second should be int.
Now one would like to do the following:
invokeMethod(obj, methodName.constData(), list);
AFAIK this is impossible. So currently a very nasty workaround is needed that is based on filling QGenericArgument objects using a loop:
for (int j=0; j<arguments.size(); j++)
const QVariant& argument = arguments[j];
invokeMethod(obj, methodName.constData(), genericArguments.value(0), genericArguments.value(1), genericArguments.value(2),
genericArguments.value(3), genericArguments.value(4), genericArguments.value(5), genericArguments.value(6), genericArguments.value(7),
This works fine but it has two drawbacks: First it uses hidden implementation details of Qt that should not be used according to the documentation. Second it is restricted to 10 arguments which is unnecessary.
As you can see this has nothing to do with the old problem how to box a QVariant in QVariant (which indeed is a problem). It is simply about an important API that doesn't exist. AFAIK it is simply impossible to write a universal IPC/RPC class using the official API. One must use the above hack or write his own code for a lot of stuff already provided by Qt.
The link I posted above has a more detailed example of the workaround.