[Interest] Fixing up console.log() in QtWebEngine
Roland Hughes
roland at logikalsolutions.com
Thu Mar 21 13:39:28 CET 2019
Steve,
You can click the SerialKeypad link in this post:
https://www.logikalsolutions.com/wordpress/raspberry-pi/raspberry-qt-part-5/
And use the LogikalLogger class for your own purposes. Expose the
singleton via a backend C++ class QML knows about (or try your hand at
exposing a singleton). It logs messages to both syslog and the console
and anyplace else you want to send them. Also understands syslog levels.
You can then call it something like this from within your QML and
JavaScript.
backEnd.logDebugMessage( "some text" + var1 + " more text: " + var2)
On 3/7/19 1:27 AM, interest-request at qt-project.org wrote:
> In a normal web browser console.log() takes one or more values as parameters and renders them for the user in some appropriate way. If the first parameter is a string containing %s style escapes it'll do some printf style formatting of the remaining parameters. (https://developers.google.com/web/tools/chrome-devtools/console/api#log ).
>
> Inside a QtWebEngine page console.log() accepts any number of parameters of any type. But by the time we get to Qt it arrives as QWebEnginePage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevellevel, const QString &message, int lineNumber, const QString &sourceID)
>
> The first parameter of console.log() is converted to a string - e.g. "[Object object]" - and delivered as a QString. The remaining parameters are discarded.
>
> That's better than nothing, but still a little annoying if you're working on javascript logic running inside a Qt app.
>
> Does anyone know where inside the Qt-Chromium interface I should start looking if I wanted to improve things?
--
Roland Hughes, President
Logikal Solutions
(630)-205-1593 (cell)
http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
More information about the Interest
mailing list