4
我现在正在移植FitNesse的Slim-server,我现在有点儿被卡住了。 什么I'm越来越像这些字符串:
用可变数量的参数调用QMetaObject :: invokeMethod()
("id_4", "call", "id", "setNumerator", "20")
("id_5", "call", "id", "setSomethingElse", "10", "8")
其中“setNumerator”和“setSomethingElse”是应该被调用和“20”,“10”和方法名“8”是我正在通过的论点。
所以我现在的问题是,我不知道如何使用一个调用invokeMethod这两种方法。我目前的解决方法是这样的:
//(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中调用需要非常具体的信息,这使得它很难与一个做可变数量的参数。另一方面,必须有一种方法,所以我不必在两次(或更晚:十次)时间内做同样的事情。
所以问题是,还有另一种方法来做一个电话?
它似乎起初工作,但它不是。 它试图用正确的参数调用正确的方法,但它失败。例如: :AddFixture :: setSummand1(QVariant)通常有效,但现在不会 – LarissaGodzilla
您可以发布您的代码吗? – crazyjul
问题是我将methodName-String转换为了Lower,所以名称没有匹配。 但现在它可以工作,所以谢谢。 – LarissaGodzilla