更新时间:2023-02-12 15:32:23
我想我已经想通了.我最终做的是在我的 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);
}