PyQt(Python+Qt)学习随笔:QTreeWidget的topLevelItemCount属性
2023-09-27 14:26:56 时间
QTreeWidget的topLevelItemCount属性是一个只读属性,用于保存树型部件中顶层项的个数,可以通过topLevelItemCount()方法获取属性值,缺省值为0。
当树型部件中顶层项的数目变化时,topLevelItemCount自动跟随变化。
案例:
def initTopItems(self):
cdriver = QtWidgets.QTreeWidgetItem(1,2,["c:\\","NTFS","10G"])
ddriver = QtWidgets.QTreeWidgetItem(["d:\\","NTFS","20G"])
edriver = QtWidgets.QTreeWidgetItem(["e:\\","NTFS","30G"])
print("1.self.treeWidget.topcount=", self.treeWidget.topLevelItemCount())
self.treeWidget.addTopLevelItem(cdriver)
print( "2.self.treeWidget.topcount=",self.treeWidget.topLevelItemCount())
self.treeWidget.addTopLevelItem(ddriver)
print("3.self.treeWidget.topcount=", self.treeWidget.topLevelItemCount())
self.treeWidget.addTopLevelItem(edriver)
print("4.self.treeWidget.topcount=", self.treeWidget.topLevelItemCount())
案例输出:
1.self.treeWidget.topcount= 0
2.self.treeWidget.topcount= 1
3.self.treeWidget.topcount= 2
4.self.treeWidget.topcount= 3
老猿Python,跟老猿学Python!
相关文章
- 利用redis的订阅和发布来实现实时监控的一个DEMO(Python版本)
- PyQt(Python+Qt)学习随笔:QScrollBar以及QAbstractSlider滚动条部件功能详解
- 第15.40节、PyQt(Python+Qt)实战:moviepy实现MP4视频转gif动图的工具
- PyQt(Python+Qt)学习随笔:QMainWindow的setDockNestingEnabled作用案例图解
- PyQt(Python+Qt)学习随笔:QWidget部件的palette属性以及ColorGroup、colorRole的用途和含义
- PyQt(Python+Qt)学习随笔:工具箱(QToolBox)的用途及标签部件项(tabbed widget item)作用介绍
- PyQt(Python+Qt)学习随笔:怎么在QScrollArea滚动区域中展示子部件的超长内容?
- PyQt(Python+Qt)学习随笔:QScrollArea的alignment属性不起作用的原因
- PyQt(Python+Qt)学习随笔:QListView的wordWrap属性
- PyQt(Python+Qt)学习随笔:QTreeView树形视图的headerHiden属性
- PyQt(Python+Qt)学习随笔:QTreeView树形视图的expandsOnDoubleClick属性
- PyQt(Python+Qt)学习随笔:QTreeView的标题表头header相关属性
- PyQt(Python+Qt)学习随笔:QTreeView树形视图的allColumnsShowFocus属性
- PyQt(Python+Qt)学习随笔:Designer中属性设置界面的属性字体使用粗黑体的含义
- PyQt(Python+Qt)学习随笔:QTableView的sortingEnabled属性
- PyQt(Python+Qt)学习随笔:QTableView的gridStyle属性
- PyQt(Python+Qt)学习随笔:QAbstractScrollArea的用途
- PyQt(Python+Qt)学习随笔:QAbstractScrollArea的sizeAdjustPolicy、horizontalScrollBarPolicy、verticalScrollB属性
- PyQt(Python+Qt)学习随笔:Designer中ItemViews类部件frameShape属性
- PyQt(Python+Qt)学习随笔:Qt Designer中怎么给toolBar添加按钮
- PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox的ButtonRole详解
- PyQt(Python+Qt)学习随笔:gridLayout的layoutRowMinimumHeight和layoutColumnMinimumWidth属性
- PyQt(Python+Qt)学习随笔:在一个窗口点击按钮弹出另一个窗口的实现方法及注意事项
- PyQt(Python+Qt)学习随笔:Qt Designer中QAbstractButton派生按钮部件的checkable和checked属性
- PyQt(Python+Qt)学习随笔:Qt Designer组件属性编辑界面中对话窗QDialog的sizeGripEnabled属性
- PyQt(Python+Qt)学习随笔:Qt Designer中部件的geometry几何属性
- PyQt(Python+Qt)学习随笔:Qt Designer中窗口对象的windowFilePath属性
- PyQt(Python+Qt)学习随笔:部件的大小策略sizePolicy的含义
- Python风靡全宇宙,首要原因竟是它?