Answer the question
In order to leave comments, you need to log in
How to make qt webkit save javascript logging level?
I ran into the following problem and I can’t figure it out: qtwebkit, when working with js on pages, displays console.warn and console.error at the debug level, and not at the corresponding warning and critical (or fatal, I’m not sure here). Tell me what can I do about it? How to combine js and qt logging?
Answer the question
In order to leave comments, you need to log in
Starting with Qt 5.6 and WebEngine, logging levels are available in the javaScriptConsoleMessage() function:
doc.qt.io/qt-5/qwebenginepage.html#javaScriptConso...
doc.qt.io/qt-5/qwebenginepage.html#JavaScriptConso.. Inherit from QWebEnginePage
, overload javaScriptConsoleMessage() and use as you need, as an example:
void WebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level,
const QString &message,
int lineNumber,
const QString &sourceID)
{
Q_UNUSED(lineNumber);
Q_UNUSED(sourceID);
switch (level) {
default:
case QWebEnginePage::InfoMessageLevel:
qDebug() << message;
break;
case QWebEnginePage::WarningMessageLevel:
qWarning() << message;
break;
case QWebEnginePage::ErrorMessageLevel:
qCritical() << message;
break;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question