Advice on how to implement if possible?
Unsolved
General and Desktop
-
I want to implement a function that is invokable from JavaScript, I want to be able to call C++ functions from JavaScript, all the controls have unique ID's.
This is what I have so far:
/** * @brief clsScriptHelper::invoke * @param crstrID Constant reference to ID for node / widget to invoke * @param crstrMethod Constant reference to method to invoke * @param crlstArgs Constant reference to stringlist containing arguments * @return true if invoke call ok else false */ bool clsScriptHelper::invoke(const QString& crstrID, const QString& crstrMethod , const QStringList& crlstArgs) { clsXMLnode* pobjNode(clsXMLnode::spobjGetNodeById(crstrID)); QWidget* pobjWidget; bool blnRC(false); if ( pobjNode != nullptr && (pobjWidget = pobjNode->pobjGetWidget()) != nullptr ) { QGenericArgument ga(crlstArgs[0].toLatin1().constData()); blnRC = QMetaObject::invokeMethod(pobjWidget, crstrMethod.toLatin1(), ga); } return blnRC; }
I'm looking for some input / help on how I could implement this? Ideally I would like to pass all the required arguments from crlstArgs.
The above has no warnings, but presently its hard coded for just a single parameter, I would like it to adapt to the number of arguments passed in the list.