Problem evaluating javascript source with QWebView
-
wrote on 7 Aug 2015, 08:26 last edited by
Hi,
I could use some help solving the following problem. I keep getting an error with the following code:
// HtmlWizard.cpp
QString scriptSource = "if (Wizard_OnNext != null)
wizard.nextButtonClicked.connect(Wizard_OnNext);";
ui.webView->page()->mainFrame()->evaluateJavaScript(scriptSource);Here I try to execute some javascriptcode with the function evaluateJavascript, it should never give an error. However when the javascript function Wizard_OnNext does not exist,
Qt shows an alert with the error:
"undefined:1: ReferenceError: Can't find variable: Wizard_OnNext"This is incorrect, since the syntax is correct. Does anybody know how I can solve this problem?
Thanks in advance,
Jelko
-
Hi,
I could use some help solving the following problem. I keep getting an error with the following code:
// HtmlWizard.cpp
QString scriptSource = "if (Wizard_OnNext != null)
wizard.nextButtonClicked.connect(Wizard_OnNext);";
ui.webView->page()->mainFrame()->evaluateJavaScript(scriptSource);Here I try to execute some javascriptcode with the function evaluateJavascript, it should never give an error. However when the javascript function Wizard_OnNext does not exist,
Qt shows an alert with the error:
"undefined:1: ReferenceError: Can't find variable: Wizard_OnNext"This is incorrect, since the syntax is correct. Does anybody know how I can solve this problem?
Thanks in advance,
Jelko
-
wrote on 11 Aug 2015, 07:15 last edited by
I try to use standard javascript code to determine if a function exists, it seems
that the Qt engine which parses javascript does not recognize it as valid javascript code. Does somebody know a workaround?Thanks in advance
-
@raf924 I am not sure what you mean: I tried different combinations. Could you give an example?
-
wrote on 13 Aug 2015, 08:09 last edited by
It now works:
QString scriptSource = "if (typeof Wizard_OnNext == 'function') { wizard.nextButtonClicked.connect(Wizard_OnNext); }";
ui.webView->page()->mainFrame()->evaluateJavaScript(scriptSource);
6/6