[Interest] Fixing up console.log() in QtWebEngine
Steve Atkins
steve at blighty.com
Mon Mar 4 14:42:12 CET 2019
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?
Cheers,
Steve
More information about the Interest
mailing list