Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QtWebEngine debugging

Tags:

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.

like image 230
Roman Kolesnikov Avatar asked Feb 23 '15 18:02

Roman Kolesnikov


2 Answers

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.

like image 115
Ian Reinhart Geiser Avatar answered Sep 20 '22 09:09

Ian Reinhart Geiser


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.

like image 43
Archie Avatar answered Sep 20 '22 09:09

Archie