我正在编写一个简单的加载屏幕,以备以后需要。我已经有一段时间没有使用PyQt了,现在一切都在尝试和失败中进行。我想要一个扩展到边界尽头的QProgressBar。但我得到的却是:
这让我觉得是布局没有扩大。我想要你的帮助和经验!谢谢!你知道吗
我的代码:
class LoadingScren(QWidget):
def __init__(self):
super().__init__()
self.windowWidth = 500
self.windowHeight = 300
self.backgroundImage = 'bg.jpg'
self.icon = 'template_icon.png'
self.iconWidht = 100
self.iconHeight = 100
self.headline = 'Headline'
self.description = """Lorem ipsum dolor sit amet"""
self.initUI()
def initUI(self):
self.setFixedSize(self.windowWidth, self.windowHeight)
self.setWindowFlag(Qt.FramelessWindowHint)
imgIcon = QLabel()
imgIcon.setPixmap(QPixmap(self.icon).scaled(self.iconWidht, self.iconHeight))
lblHeadline = QLabel()
lblHeadline.setText(self.headline)
lblHeadline.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
lblHeadline.setStyleSheet('font-size: 75px')
lblDescription = QLabel()
lblDescription.setScaledContents(True)
lblDescription.setText(self.description)
lblDescription.setStyleSheet('font-size: 25px')
progressBar = QProgressBar()
progressBar.setMaximumHeight(2)
progressBar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
headerLayout = QHBoxLayout()
headerLayout.addWidget(imgIcon)
headerLayout.addWidget(lblHeadline)
mainLayout = QVBoxLayout()
mainLayout.addLayout(headerLayout)
mainLayout.addWidget(lblDescription)
mainLayout.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
mainLayout.addWidget(progressBar)
self.setLayout(mainLayout)
self.show()
使用
progressBar.setTextVisible(False)
或者
Qt样式表
progressBar.setStyleSheet(...)
相关问题 更多 >
编程相关推荐