如何抑制来自QWebEngineView错误的控制台输出?

Esostack

如果从不同工作目录中的Python实例创建QWebEngineView实例,则会出现以下错误:

[2452:9872:1108/052617.050:ERROR:cache_util_win.cc(21)] Unable to move the cache: Access is denied. (0x5)
[2452:9872:1108/052617.050:ERROR:cache_util.cc(135)] Unable to move cache folder C:\Users\Adam\AppData\Local\python\QtWebEngine\Default\GPUCache to C:\Users\Adam\AppData\Local\python\QtWebEngine\Default\old_GPUCache_000
[2452:9872:1108/052617.051:ERROR:disk_cache.cc(184)] Unable to create cache
[2452:9872:1108/052617.056:ERROR:shader_disk_cache.cc(606)] Shader Cache Creation failed: -2
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
from PyQt5.QtCore import Qt
app = QtWidgets.QApplication([])
x = QtWebEngineWidgets.QWebEngineView()
x.load(QtCore.QUrl('http://example.com/'))

在此处输入图片说明

看来这是一个已知问题,将在QT6中修复:https ://bugreports.qt.io/browse/QTBUG-66014

但是与此同时,我如何隐藏此消息?我尝试更改,QtCore.qInstallMessageHandler并且也x.page().javaScriptConsoleMessage = lambda self, level, msg, line, sourceID: None没有影响此消息。

永乐

一种可能的解决方案是提高铬原木的含量:

import os
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets

os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--enable-logging --log-level=3"
app = QtWidgets.QApplication([])
x = QtWebEngineWidgets.QWebEngineView()
# ...

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章