When calling the Q_INVOKABLE method written in C++ from a JavaScript function in QML , how did you choose the exception? This method belongs to an object of type < MyApp > registered with the qmlRegisterType() call qmlRegisterType()
For example, I have the following QML code:
TextField { id: fld_recipient onEditingFinished: { try { var identity=myapp.identities.current_Identity; var company=identity.companies.current_Company; myapp.lookup_email(identity.identity_id,company.company_id,fld_recipient.text) } catch(e) { console.log(e); } } }
Here, the MyApp :: lookup_email () method is sent to the server and looks for the corresponding email addresses. This process can be stopped by a lot of errors, and I want the catch () operator to display this error.
How is this done on the C ++ side? A view like this:
void MyApp::lookup_email(int identity_id,int company_id,QString email) { .... error_code=server->lookup_email(identity_id,company_id,email); if (error_code) {
Nulik source share