标题:用QtDesiger设计UI界面显示网页内容出现的问题
取消只看楼主
huangyz_xy
Rank: 2
等 级:论坛游民
帖 子:101
专家分:30
注 册:2016-10-2
结帖率:77.78%
 问题点数:0 回复次数:0 
用QtDesiger设计UI界面显示网页内容出现的问题
我想将网页页面显示在用QtDesiger设计的界面上,因为QtDesiger没有QtWebEngineWidgets控件,已经手动安装,编译后的文件名为“图表_UI.PY”,内容如下:
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtWebEngineWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(821, 530)
        self.groupBox = QtWidgets.QGroupBox(Form)
        self.groupBox.setGeometry(QtCore.QRect(290, 80, 521, 441))
        self.groupBox.setObjectName("groupBox")
        self.browser = QtWebEngineWidgets.QWebEngineView(self.groupBox)
        self.browser.setGeometry(QtCore.QRect(9, 19, 501, 411))
        self.browser.setObjectName("browser")
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(330, 10, 191, 51))
        font = QtGui.QFont()
        font.setFamily("宋体")
        font.setPointSize(18)
        self.label.setFont(font)
        self.label.setObjectName("label")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.groupBox.setTitle(_translate("Form", "图表展示区"))
        self.label.setText(_translate("Form", "图表可视化"))
***********************************************************************************
使用代码和界面分离的方式实现显示,代码如下:
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtCore import QUrl
from 图表_UI import Ui_Form
import os
import sys


class Chart_Form(QMainWindow, Ui_Form):
    def __init__(self, parent=None):
        super(Chart_Form, self).__init__(parent)
        self.setupUi(self)
        self.browser.load(QUrl(https://www.baidu.com/))
        self.setCentralWidget(self.browser)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    mainWindow = QWidget()
    ui = Chart_Form()
    ui.setupUi(mainWindow)
    mainWindow.show()
    sys.exit(app.exec_())

执行时代码无报错提示,但是就是在显示区中无内容!
如果去掉所有继承,单独用以下代码是可以显示的:
self.browser = QtWebEngineWidgets.QWebEngineView()
self.browser.load(QUrl(https://www.baidu.com/))
self.setCentralWidget(self.browser)

请高手指教,是哪儿出问题了,谢谢!
搜索更多相关主题的帖子: 显示 browser Form from import 
2021-01-21 10:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-504685-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.263749 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved