首页 文章

PyQt5 QWebEngineView无法正常工作

提问于
浏览
1

此代码在执行时不显示任何内容 . 甚至不是主窗口 . 如何使用QWebEngineView()来创建有用的代码 .

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
import sys

class MainWindow(QMainWindow):

    def __init__(self, *args, **kwargs):

        super(MainWindow, self).__init__(*args, **kwargs)

        self.setWindowTitle('Browser Lite')
        self.setGeometry(5, 30, 1355, 730)


        self.browser = QWebEngineView()
        self.browser.load(QUrl('http://www.google.com'))

        self.setCentralWidget(self.browser)

app = QApplication(sys.argv)
win = MainWindow()
win.show()
app.exec_()

1 回答

  • 0

    如果您的意思是空白屏幕,请尝试添加以下内容

    from OpenGL import GL # apt install python3-opengl ..will get blank screen and console spam "shader program is not linked"
    

    有关完整示例,您可以查看以下内容simplebrowser/pyqt5

相关问题