更新时间:2023-02-12 16:38:24
我想我已经弄明白了。我最终做的是在我的C ++类中实现这样:
I think I've figured this out. What I ended up doing was implementing this in my C++ class like such:
class MyObject: public QObject
{
Q_OBJECT
public:
Q_INVOKABLE void doSomething(quint64 x, QJSValue jsCallback)
{
x += 1;
QJSValue val = jsCallback.engine()->newObject();
val.setProperty("x", x);
jsCallback.call(QJSValueList { val });
}
};
然后我可以在我的回调中访问该值,如:
And then I can access the value in my callback like:
function myCallback(x){
console.log("x=" + x.x);
}