我需要内嵌一个网页,然后有一个按钮,用来显示或者隐藏这个网页
显示页面的时候最大化,隐藏页面的时候恢复到为显示页面时组件的大小
1、最开始只用了包含网页的容器self.ext的show和hidden,点击展示的时候根本无法页面,虽然能手动缩放,但是布局不可控
2、然后使用了
mainLayout.setSizeConstraint(QLayout.SetFixedSize)
解决了显示和隐藏的功能,但是不能缩放
3、尝试在显示和隐藏的时候对父组件使用resize,但是resize实际上重置组件的大小
import sys
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl,Qt
from PyQt5.QtWidgets import QWidget, QLabel, QApplication,QMainWindow,QVBoxLayout,QHBoxLayout,QLineEdit,QPushButton,QLayout
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.initUi()
def initUi(self):
topLayout = QHBoxLayout()
label = QLabel("号码")
edit = QLineEdit()
hidbutton = QPushButton("展示")
hidbutton.clicked.connect(self