It works just fine for me.
#include <QtGui>
#include <QtQml>
int main(int argc, char **argv) {
QGuiApplication app(argc, argv);
QQmlEngine e;
QQmlComponent c(&e, "test.qml");
QVariantMap m;
m["i"] = 10;
m["name"] = "someName";
// return app.exec();
return 0;
}
#include <QtGui>
#include <QtQml>
int main(int argc, char **argv) {
QGuiApplication app(argc, argv);
QQmlEngine e;
QQmlComponent c(&e, "test.qml");
QObject *o = c.create();
QVariantMap m;
m["i"] = 10;
m["name"] = "someName";
QVariant v = m;
QVariant ret;
QMetaObject::invokeMethod(o, "testFunc", Q_RETURN_ARG(QVariant, ret), Q_ARG(QVariant, v));
// return app.exec();
return 0;
}
To copy to clipboard, switch view to plain text mode
import QtQml 2.0
QtObject {
function testFunc(v) { console.log("v.name = ", v.name); }
}
import QtQml 2.0
QtObject {
function testFunc(v) { console.log("v.name = ", v.name); }
}
To copy to clipboard, switch view to plain text mode
Bookmarks