'Print Javascript Exceptions In A QWebView To The Console
I'm using PyQt4 and a QWebView widget to view a webpage, but it appears as though there is a problem with my Javascript. Other browsers seem to run ok, so I would like to know if any exceptions are occurring by printing them to the console.
The code I'm using is below. What do I need to add to do this?
from PyQt4 import QtGui, QtWebKit
browser = QtWebKit.QWebView()
browser.load(QtCore.QUrl("http://myurl"))
browser.show()
Thanks, Andrew
Solution 1:[1]
Or you could just set the DeveloperExtrasEnabled setting. This will allow you to right-click the QWebView and select Inspect.
from PyQt5.QtWebKit import QWebSettings
QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Wladimir Palant |
