QT 5.4 WebEngine dev tools for javascript

不羁岁月 提交于 2019-12-05 16:44:40

add these line to your code

#ifdef QT_DEBUG
    qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "9000");
#endif

after launching your application start google chrome then navigate to http://localhost:9000 you will get developer tools

You can do it with older QWebView, see QWebSettings::DeveloperExtrasEnabled.

Docs have nothing about same for QWebEngineView, but I found this link (look at line 47). I didn't try if it works, but you can try. May be dev tools will be available in one of the following QT versions.

And here is a bit more flexible solution: to launch application with command line parameter --remote-debugging-port=XXXX. It's automatically routed by QApplication to the Blink (or whatever QWebEngine is) internals, so there is no additional work like arguments parsing needed; and it can be changed without app rebuild.

Upd: frankly speaking, I had used it only with 5.5 & 5.6, perhaps it unsupported in 5.4

set command line "remote-debugging-port=XXXX";but there's a problem, when the application exit, it will produce a crash

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