Qt WebEngine Debugging and Profiling
Console Logging
JavaScript executed inside Qt WebEngine can use the Chrome console API to log information to a console. The logging messages are forwarded to Qt's logging facilities inside a js logging category. However, only warning and fatal messages are printed by default. To change this, you either have to set custom rules for the js category, or provide custom message handlers by reimplementing QWebEnginePage::javaScriptConsoleMessage(), or connecting to WebEngineView::javaScriptConsoleMessage().
All messages can also be accessed through the Qt WebEngine developer tools.
Qt WebEngine Developer Tools
The Qt WebEngine module provides web developer tools that make it easy to inspect and debug layout and performance issues of any web content.
The developer tools are accessed as a local web page using a Chromium or Qt WebEngine based browser, such as the Chrome browser.
To activate the developer tools, start an application that uses Qt WebEngine with the command-line arguments:
--remote-debugging-port=<port_number>
Where <port_number> refers to a local network port. The web developer tools can then be accessed by launching a browser at the address http://localhost:<port_number>.
Alternatively, the environment variable QTWEBENGINE_REMOTE_DEBUGGING can be set. It can be set as either just a port working similarly to --remote-debugging-port or given both a host address and a port. The latter can be used to control which network interface to export the interface on, so that you can access the developer tools from a remote device.
For a detailed explanation of the capabilities of developer tools, see the Chrome DevTools page.
Using Command-Line Arguments
You can use the following command-line arguments while debugging to provide input for bug reports:
--disable-gpu disables GPU hardware acceleration. This is useful when diagnosing OpenGL problems.
--disable-logging disables console logging, which might be useful for debug builds.
--enable-logging --log-level=0 enables console logging and sets the logging level to 0, which means that messages of the severity info and above are recorded in the log. This is the default for debug builds. Other possible log levels are 1 for warnings, 2 for errors, and 3 for fatal errors.
--no-sandbox disables the sandbox for the renderer and plugin processes. Keep in mind that disabling the sandbox might present a security risk.
--single-process runs the renderer and plugins in the same process as the browser. This is useful for getting stack traces for renderer crashes.
Alternatively, the environment variable QTWEBENGINE_CHROMIUM_FLAGS can be set. For example, the following value could be set to disable logging while debugging an application called mybrowser:
QTWEBENGINE_CHROMIUM_FLAGS="--disable-logging" mybrowser
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
2016-05-20 MVC,MVP 和 MVVM 的图示
2016-05-20 MVVM 一种新型架构框架
2016-05-20 Linq 之 Where操作
2016-05-20 Linq To SQL和Linq To Object的批量操作InsertAllOnSubmit介绍