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

yipeiwu_com6年前Python基础

如下所示:

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(滚动条)的使用方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python竟能画这么漂亮的花,帅呆了(代码分享)

Python竟能画这么漂亮的花,帅呆了(代码分享)

阅读本文大概需要3分钟 关于函数和模块讲了这么久,我一直想用一个好玩有趣的小例子来总结一下,同时也作为实战练习一下。 趣味编程其实是最好的学习途径,回想十几年前我刚毕业的时候,第一份工...

python类中super() 的使用解析

描述 super() 函数是用于调用父类(超类)的一个方法。 super 是用来解决多重继承问题的,直接用类名调用父类方法在使用单继承的时候没问题,但是如果使用多继承,会涉及到查找顺序...

python文件特定行插入和替换实例详解

python文件特定行插入和替换实例详解 python提供了read,write,但和很多语言类似似乎没有提供insert。当然真要提供的话,肯定是可以实现的,但可能引入insert会带...

在cmder下安装ipython以及环境的搭建

在cmder下安装ipython以及环境的搭建

打开cmder 1.移动到D盘 输入命令:D: 2.创建文件夹 λ mkdir myApp 3.创建python自带的虚拟环境 λ python -m venv...

python贪婪匹配以及多行匹配的实例讲解

1 非贪婪flag >>> re.findall(r"a(\d+?)", "a23b") ['2'] >>> re.findall(r...