QWebChannel: Invoking C++ methods from Js, with complex arguments
-
wrote on 17 Jan 2015, 13:48 last edited by
Hi,
I've set up a qwebchannel client/server application the same way as it's done in the "standalone" example: https://github.com/qtproject/qtwebchannel/tree/dev/examples/webchannel/standaloneI can successfully invoke C++ methods from JavaScript, but I can't find a way to pass complex arguments like arrays or objects.
To be more specific, this is my personal C++ method:
@void receiveMessage(QString msg, QVariant data);@And these are some calls from JavaScript
@registeredObject.receiveMessage("HELLO", "something") // Works
registeredObject.receiveMessage("HELLO", 45) // Works
registeredObject.receiveMessage("HELLO", [45]) // DOESN'T work
registeredObject.receiveMessage("HELLO", {some: "thing"}) // DOESN'T work@With "doesn't work" I mean that the application crashes. When I'm within the receiveMessage() method, the debugger says that the "data" argument is not accessible.
I suspect (but it's only a suspect) that the problem lies somewhere here: https://github.com/qtproject/qtwebchannel/blob/dev/src/webchannel/qmetaobjectpublisher.cpp#L361
What can I do to fix it? Am I doing it wrong?
Thanks
1/1