它在Qt文档中:
注意:如果以下任一项,QWebInspector将显示一个空白小部件:page()为null QWebSettings :: DeveloperExtrasEnabled为false
您必须启用它,如下所示:
import sys from PySide.QtCore import * from PySide.QtGui import * from PySide.QtWebKit import * app = QApplication(sys.argv) web = QWebView() web.settings().setAttribute( QWebSettings.WebAttribute.DeveloperExtrasEnabled, True) # or globally: # QWebSettings.globalSettings().setAttribute( # QWebSettings.WebAttribute.DeveloperExtrasEnabled, True) web.load(QUrl("http://www.google.com")) web.show() inspect = QWebInspector() inspect.setPage(web.page()) inspect.show() sys.exit(app.exec_())