我编写了一个简单的测试程序以在QWebEngineView中加载URL。该程序可在Mac上运行;浏览器弹出,我可以看到该网页。但是在Windows 7上,在我调用show()之后,浏览器窗口永远不会出现:
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl
class Browser(QWebEngineView):
def __init__(self):
super().__init__()
self.load(QUrl('https://google.com'))
self.loadFinished.connect(self.pageReady)
def pageReady(self, success):
if success:
self.show()
else:
print('page failed to load')
if __name__ == '__main__':
app = QApplication(sys.argv)
browser = Browser()
app.exec_()
有什么我想念的吗?我的防火墙已禁用,因此应该不是连接问题...