python - view.showMaximized() 在 PyQt5 中不起作用

标签 python python-3.x pyqt pyqt5

我正在使用PyQt5制作一个网络浏览器。我正在使用以下代码:

import PyQt5
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtWebKitWidgets import QWebView , QWebPage
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtNetwork import *
import sys
from optparse import OptionParser

class Browser(QWebView):
    def __init__(self):
        # QWebView
        self.view = QWebView.__init__(self)
        #self.view.setPage(MyBrowser())
        self.setWindowTitle('Loading...')
        self.titleChanged.connect(self.adjustTitle)
        #super(Browser).connect(self.ui.webView,QtCore.SIGNAL("titleChanged (const QString&)"), self.adjustTitle)

    def load(self,url):
        self.setUrl(QUrl(url))

    def adjustTitle(self):
        self.setWindowTitle(self.title())

app = QApplication(sys.argv)
view = Browser()
view.showMaximized()
view.load("https://duckduckgo.com")
app.exec_()

但是,这就是我得到的:screenshot

有人可以告诉我哪里出错了吗?请注意,这不是网站的问题。我已经在 Wikipedia、Stack Overflow 和 Google 上尝试过。我使用的是 PyQt5 版本 5.10.1。

最佳答案

如果您想要全屏,则必须使用:

class Browser(QWebView):
    def __init__(self):
        # QWebView
        self.view = QWebView.__init__(self)
        #self.view.setPage(MyBrowser())
        self.setWindowTitle('Loading...')
        self.titleChanged.connect(self.adjustTitle)
        self.showFullScreen()

关于python - view.showMaximized() 在 PyQt5 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57505915/

相关文章:

python - 运行pytest时如何让pycharm输出颜色?

python - 使用 OpenAI Gym 构建 mujoco-py 的轮子失败

python - 使用 Pyinstaller 编译 PyQt4 时出错

python - 如何使用 Python 流套接字作为代理?

python - 连接多个数据帧

Python之tkinter智能录入密码

python - 使用 selenium webdriver_manager 在 unix 上打开 Chrome 浏览器时出错

python - 用 pyqt 扩展 QGraphicsItem

Python:RuntimeError:从未调用过 %S 的父类(super class) __init__()

Python 3.x C API : Do I have to free the memory after extracting a string from a PyObject?