【发布时间】:2011-10-11 16:27:45
【问题描述】:
我现在正在移植 FitNesse 的 Slim 服务器,我现在有点卡住了。
我得到的是这样的字符串:
("id_4", "call", "id", "setNumerator", "20")
("id_5", "call", "id", "setSomethingElse", "10", "8")
其中“setNumerator”和“setSomethingElse”是应该调用的方法的名称,“20”、“10”和“8”是我传递的参数。
所以我现在的问题是,我不知道如何使用 one 调用来调用这两种方法。我目前的解决方法如下:
//(if instructionLength==5)
metaObj->invokeMethod(className, methodName.toAscii().constData(), Qt::DirectConnection,
Q_ARG(QVariant, instructions.at(index).at(4)))
//(if instructionLength==6)
metaObj->invokeMethod(className, methodName.toAscii().constData(), Qt::DirectConnection, Q_RETURN_ARG(QVariant, retArg),
Q_ARG(QVariant, instructions.at(index).at(4)),
Q_ARG(QVariant, instructions.at(index).at(5)))
等等...
因此,一方面,似乎每个 invokeMethod 调用都需要非常具体的信息,这使得使用可变数量的参数很难做到这一点。另一方面,必须有一种方法,这样我就不必两次(或更晚:十次)做同样的事情。
所以问题是,有没有另一种方法可以通过一个电话来做到这一点?
【问题讨论】: