Reputation: 1379
I've started to embed some QWebView widgets to my desktop application (PyQt).
I use JQuery and CSS to enhance appearance and usability.
It would be comfortable to debug my html code with a web inspector.
How can I embed Firebug Lite in my QWebView widgets?
E.g. I tried the following code and it doesn't work:
html1 = """
<html debug="true">
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.js"></script>
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js#startOpened=true"></script>
<script type="text/javascript">
$(document).ready(function() {
$("body").css("background", "#f00");
console.log("in here");
});
</script>
</head>
<body><h1>Hello!</h1></body>
</html>
"""
html2 = """
<html debug="true">
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("body").css("background", "#f00");
var firebugLite = document.createElement("script");
firebugLite.src = "https://getfirebug.com/firebug-lite.js";
firebugLite.id = "firebug_lite";
firebugLite.textContent = "{ startOpened: true }";
document.getElementsByTagName("head")[0].appendChild(firebugLite);
console.log("in here");
});
</script>
</head>
<body><h1>Hello!</h1></body>
</html>
"""
if __name__ == '__main__':
app = QApplication(sys.argv)
view = QWebView()
frame = view.page().mainFrame()
frame.setHtml(html2)
view.show()
app.exec_()
html1 and html2 have the same effect: body turns into red but Firebug doesn't show up.
P.S. my actual html code can't be debug with an external client browser,
because it uses QT resources and application window objects.
Upvotes: 2
Views: 1564
Reputation: 5117
I've added this JavaScript to my WebKit-based projects, maybe this helps for QWebView as well?
var firebugLite = document.createElement("script");
firebugLite.src = "https://getfirebug.com/firebug-lite.js";
firebugLite.id = "firebug_lite";
firebugLite.textContent = "{ startOpened: true }";
document.getElementsByTagName("head")[0].appendChild(firebugLite);
Upvotes: 3