QtWebEngine debugging

爱⌒轻易说出口 提交于 2019-11-27 14:32:47

问题


Recently Qt introduced the QtWebEngine module. Is there a way to invoke developer tools and debug JavaScript code inside QWebEngineView? It was possible with QWebView using

page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);

but I couldn't find any similar option in QWebEngineView.


回答1:


I just ran across this so I added it here for posterity.

It was just added to Qt 5.5 git. You have to enable it via an environment variable QTWEBENGINE_REMOTE_DEBUGGING=<port>. You can put 0.0.0.0:<port> if you are doing debugging of an embedded device and cant use the local console. Then you can point can connect to http://127.0.0.1: to get the debugger. It will need to be a chromium based browser. Do you have to use Chrome, or you can actually use the "quick nano browser" example if you want.




回答2:


Alternatively, one may embed Firebug Lite to get a JavaScript console and inspectors.

Just add

<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>

into the page. Pressing F12 will visualize the Firebug console.




回答3:


From http://blog.qt.io/blog/2015/03/17/qt-5-5-alpha-available/:

The remote inspector can be used by either defining the env variable QTWEBENGINE_REMOTE_DEBUGGING, or by supplying the –remote-debugging-port command line argument. You can then point a browser at the specified port and inspect your web content.




回答4:


look this:

The Chromium DevTools provide the ability to inspect and debug layout and performance issues of any web content

https://doc.qt.io/qt-5/qtwebengine-features.html#chromium-devtools



来源:https://stackoverflow.com/questions/28681141/qtwebengine-debugging

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!