|
|

楼主 |
发表于 2024-2-21 22:10:00
|
显示全部楼层
实在惭愧,我现有如下代码,但是实在是没有能力把滚动条引入到窗体中。。。。。
import sys
import time
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtWidgets import QWidget, QApplication
from CustomProgressBar import CustomProgressBar
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
# 设置第四个垂直布局
self.verticalLayoutWidget_4 = QtWidgets.QWidget(parent=Form)
self.verticalLayoutWidget_4.setGeometry(QtCore.QRect(450, 790, 500, 20))
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_4)
self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.label_5 = QtWidgets.QLabel(parent=self.verticalLayoutWidget_4)
font = QtGui.QFont()
font.setFamily("隶书")
font.setPointSize(18)
self.label_5.setFont(font)
self.label_5.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.label_5.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_5.setObjectName("label_5")
self.verticalLayout_4.addWidget(self.label_5)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
class MyForm(QtWidgets.QWidget, Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.label_5.hide()
# self.progressBar.hide()
# label_4垂直居中对齐
label_4_height = self.label_4.height()
label_4_y = y + (windowRect.height() - label_4_height) // 2
self.label_4.move(self.label_4.x(), label_4_y)
def connectSignals(self):
# 连接信号和槽
self.pushButton.clicked.connect(self.checkLogin)
# self.pushButton_3.clicked.connect(self.adjustOptions)
# self.pushButton_4.clicked.connect(self.showHelpForm)
self.pushButton_2.clicked.connect(self.confirmExit)
def checkLogin(self):
# 检查用户名和密码
username = self.lineEdit.text()
password = self.lineEdit_2.text()
# 模拟检查逻辑
if username == "aaa" and password == "1":
self.showSuccessMessage()
else:
self.showErrorMessage()
##########################
def showSuccessMessage(self):
msgBox = QtWidgets.QMessageBox()
msgBox.setText("登录成功!欢迎使用本报表统计系统!")
msgBox.setWindowTitle("成功")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("success.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
msgBox.setWindowIcon(icon)
msgBox.exec()
time.sleep(1)
self.label_5.show()
## 我希望在这从0%开始显示滚动条###
# 判断滚动条是否达到 100%
if self.progressBar.value() == 100:
# 打开主窗口
mainWindow = MainWindow()
mainWindow.show()
self.close() # 关闭当前窗口
else:
event.ignore() # 忽略关闭事件
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
# 主窗口的初始化代码
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
myForm = MyForm()
myForm.show()
sys.exit(app.exec())
请问一下:究竟要怎样才能把滚动条加入进去?
回复请注意python 格式 |
|