在PYQT5中QscrollArea(滚动条)的使用方法
如下所示:
import sys from PyQt5.QtWidgets import * class MainWindow(QMainWindow): def __init__(self,): super(QMainWindow,self).__init__() self.number = 0 w = QWidget() self.setCentralWidget(w) self.topFiller = QWidget() self.topFiller.setMinimumSize(250, 2000)#######设置滚动条的尺寸 for filename in range(20): self.MapButton = QPushButton(self.topFiller) self.MapButton.setText(str(filename)) self.MapButton.move(10,filename*40) ##创建一个滚动条 self.scroll = QScrollArea() self.scroll.setWidget(self.topFiller) self.vbox = QVBoxLayout() self.vbox.addWidget(self.scroll) w.setLayout(self.vbox) self.statusBar().showMessage("底部信息栏") self.resize(300, 500) if __name__ == "__main__": app = QApplication(sys.argv) mainwindow = MainWindow() mainwindow.show() sys.exit(app.exec_())
出来的效果
相关推荐
letheashura 2020-05-10
sixthelement 2020-04-30
songfens 2019-12-06
JayFighting 2019-12-02
RexLeee 2019-11-10
大地飞鸿 2019-11-08
zZoOoOJaVa 2014-06-24
Martnn 2019-11-05
echoes 2019-11-03
sdbxpjzq 2019-10-25
dly 2015-05-29