网络编程
位置:首页>> 网络编程>> Python编程>> 在PYQT5中QscrollArea(滚动条)的使用方法

在PYQT5中QscrollArea(滚动条)的使用方法

作者:张得帅!  发布时间:2023-03-07 06:29:51 

标签: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_())

出来的效果

在PYQT5中QscrollArea(滚动条)的使用方法

来源:https://blog.csdn.net/qq_37946291/article/details/80540903

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com