0

Inside a function which IS getting called through Qt's QWebView:

document.write ("11");

The above statement doesn't show anything on the console!

I want it to get displayed on the "console". I am running the qt executable as "./showmap" and then a widget gets displayed on which the map is shown. On a button click, a function gets called and in that function I have written document.write("11"); which doesn't seem to be doing anything normal.

1 Answer 1

2
+50

That's what document.write does. It writes to the document.

To write to the OS's standard output or standard error, subclass QWebPage and override javascriptConsoleMessage.

Here is an example:

http://wiki.forum.nokia.com/index.php/Redirecting_JavaScript_console_messages_in_a_Qt_hybrid_application

Once you've overridden javascriptConsoleMessage to write to the operating system's stdout/stderr (with qDebug), calls to console.log will write to stdout/stderr as well.

As an alternative, overriding javascriptAlert() and then calling alert() in your Javascript should do the same thing.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Dugan, but it didn't do what I wanted, see LQ. P.S. I'll edit the question now.
I'll add the reasons here too, just for the sake: I tried your method, that was indeed helpful in getting the "error messages". But my question is how should I "print a variable" on the "Linux console" from Javascript functions. I am not talking of error messages here, I just want to see what the variables contain.
and bounty can't be awarded before 23 hours :rolleyes:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.