I have a connect that works which connects a signal in C++ to a slot in JavaScript:
Object::connect(this, &clsQtPushBtn::clicked
,[pobjScriptEng, strCall, strFile, strScript]() {
QString strScriptWithCall = static_cast<QString>(strStript)
+ static_cast<QString>(strCall) + "();";
pobjScriptEng->evaluate(strScriptWithCall);
});
In the above code:
this is an instance of my PushButton class clsQtPushBtn. clsQtPushBtn::clicked is the address of the "clicked" signal. pobjScriptEng is a pointer to an instance of QJSEngine*. strCall is a JavaScript function "test". strFile is the name of the JavaScript file "simon2.js". strScript is the content of the JavaScript file which contains the function test().
The question is how do a make the equivalent disconnect call as I'm having difficulty with it, there are 7 options and just changing connect for disconnect does not work, I get:
no matching member function for call to 'disconnect'
The QObject::connect function returns a QMetaObject::Connection so you can pass it to QObject::disconnect.