我在我的应用程序中使用QWebEngineView。升级到PyQt6之后,它已经开始输出如下所示的日志记录信息。如何禁用这些消息?
我在这里找到了发射它们的代码:logContext
看起来我必须将webEngineContextLog.isInfoEnabled()的输出更改为False,但还不清楚如何实现这一点。
测井输出:
qt.webenginecontext:
GL Type: desktop
Surface Type: OpenGL
Surface Profile: CompatibilityProfile
Surface Version: 4.6
QSG RHI Backend: OpenGL
Using Supported QSG Backend: yes
Using Software Dynamic GL: no
Using Multithreaded OpenGL: yes
Init Parameters:
* application-name python
* browser-subprocess-path C:\Users\xxx\miniconda3\envs\xxx\lib\site-packages\PyQt6\Qt6\bin\QtWebEngineProcess.exe
* create-default-gl-context
* disable-es3-gl-context
* disable-features ConsolidatedMovementXY,InstalledApp,BackgroundFetch,WebOTP,WebPayments,WebUSB,PictureInPicture
* disable-speech-api
* enable-features NetworkServiceInProcess,TracingServiceInProcess
* enable-threaded-compositing
* in-process-gpu
* use-gl desktop
可复制的最低限度代码:
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWebEngineWidgets import QWebEngineView
app = QApplication(['test'])
QWebEngineView().settings()
发布于 2022-12-04 21:29:55
今天,当我试图将一个无声的单元测试集成到我当前的项目中时,我遇到了同样的问题。
在进行了快速调查并查看了如何在函数这里中记录logContext之后,我想出了以下解决方案,对我来说很好:
from PySide6.QtCore import QUrl, QLoggingCategory
from PySide6.QtWidgets import (QApplication, QMainWindow)
from PySide6.QtWebEngineWidgets import QWebEngineView
web_engine_context_log = QLoggingCategory("qt.webenginecontext")
web_engine_context_log.setFilterRules("*.info=false")
web_view = QWebEngineView()
https://stackoverflow.com/questions/74499940
复制相似问题