本文整理汇总了Python中PyQt5.QtWidgets.QTreeWidget.columnCount方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidget.columnCount方法的具体用法?Python QTreeWidget.columnCount怎么用?Python QTreeWidget.columnCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTreeWidget
的用法示例。
在下文中一共展示了QTreeWidget.columnCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MemUsageDialog
# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import columnCount [as 别名]
class MemUsageDialog(QDialog):
def __init__(self, parent=None, update=True):
QDialog.__init__(self, parent=parent)
layout = QVBoxLayout()
self.tree = QTreeWidget()
layout.addWidget(self.tree)
self.setLayout(layout)
self._mgr = CacheMemoryManager()
self._tracked_caches = {}
# tree setup code
self.tree.setHeaderLabels(
["cache", "memory", "roi", "dtype", "type", "info", "id"])
self._idIndex = self.tree.columnCount() - 1
self.tree.setColumnHidden(self._idIndex, True)
self.tree.setSortingEnabled(True)
self.tree.clear()
self._root = TreeNode()
# refresh every x seconds (see showEvent())
self.timer = QTimer(self)
if update:
self.timer.timeout.connect(self._updateReport)
def _updateReport(self):
# we keep track of dirty reports so we just have to update the tree
# instead of reconstructing it
reports = []
for c in self._mgr.getFirstClassCaches():
r = MemInfoNode()
c.generateReport(r)
reports.append(r)
self._root.handleChildrenReports(
reports, root=self.tree.invisibleRootItem())
def hideEvent(self, event):
self.timer.stop()
def showEvent(self, show):
# update once so we don't have to wait for initial report
self._updateReport()
# update every 5 sec.
self.timer.start(5*1000)