[Solved] Debugging scripts that run in a QWebView widget



  • Hi there,
    anybody knows how to debug scripts that run into a QWebView widget?

    I've thought about attaching a QScriptEngineDebugger to the QScriptEngine of the main QWebFrame of that widget, but to the best of my searches on the web and in the documentation, there is no QScriptEngine accessible from the QWebFrame interface - I wonder what engine gets used by the evaluateJavaScript() slot.

    Any hint or suggestion?

    Thanks a lot for your attention!



  • Silly me, I can use the QWebInspector... sorry for the noise!



  • Another solution, less intrusive is to subclass webpage and reimplement:
    @
    virtual void javaScriptAlert ( QWebFrame * frame, const QString & msg )
    virtual bool javaScriptConfirm ( QWebFrame * frame, const QString & msg )
    virtual void javaScriptConsoleMessage ( const QString & message, int lineNumber, const QString & sourceID )
    virtual bool javaScriptPrompt ( QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result )
    @

    [EDIT: added code formatting tags, Volker]



  • Thanks a lot for your follow-up Florent, that technique will indeed come useful.



  • How can I add QWebInspector to QWebView? I couldn't find any sample code.



  • I just enabled it by adding this line in the constructor of my main window:

    @
    QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    @

    Then I right-click on any QWebView at runtime and I select "Inspect" - more knowledgeable people around will give deeper insight, eventually.



  • Thanks a lot, entuland. It was really helpful.

    [quote author="entuland" date="1294223335"]I just enabled it by adding this line in the constructor of my main window:

    @
    QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    @

    Then I right-click on any QWebView at runtime and I select "Inspect" - more knowledgeable people around will give deeper insight, eventually.[/quote]



  • Another interesting idea that I worked with is use JsLint inside the frame.



  • Do you have sample code? Thanks.



  • Some example about using JsLint in the Qt context would interest me too!



  • Thank you! This saved me a patch of hair or two.



  • Hello entuland,

    Could you please advise what solution was selected. I have the same question and still have no solution.

    Thank you in advance,
    Vadim


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.