本文整理汇总了Python中qgis.PyQt.QtGui.QStandardItemModel.setHorizontalHeaderLabels方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItemModel.setHorizontalHeaderLabels方法的具体用法?Python QStandardItemModel.setHorizontalHeaderLabels怎么用?Python QStandardItemModel.setHorizontalHeaderLabels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtGui.QStandardItemModel
的用法示例。
在下文中一共展示了QStandardItemModel.setHorizontalHeaderLabels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: populateTable
# 需要导入模块: from qgis.PyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from qgis.PyQt.QtGui.QStandardItemModel import setHorizontalHeaderLabels [as 别名]
def populateTable(self, table):
cols = len(self.param.headers())
rows = len(table) // cols
model = QStandardItemModel(rows, cols)
# Set headers
model.setHorizontalHeaderLabels(self.param.headers())
# Populate table
for row in range(rows):
for col in range(cols):
item = QStandardItem(str(table[row * cols + col]))
model.setItem(row, col, item)
self.tblView.setModel(model)
示例2: ConfigDialog
# 需要导入模块: from qgis.PyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from qgis.PyQt.QtGui.QStandardItemModel import setHorizontalHeaderLabels [as 别名]
class ConfigDialog(BASE, WIDGET):
def __init__(self, showSearch=True):
super(ConfigDialog, self).__init__(None)
self.setupUi(self)
self.groupIcon = QIcon()
self.groupIcon.addPixmap(self.style().standardPixmap(
QStyle.SP_DirClosedIcon), QIcon.Normal, QIcon.Off)
self.groupIcon.addPixmap(self.style().standardPixmap(
QStyle.SP_DirOpenIcon), QIcon.Normal, QIcon.On)
self.model = QStandardItemModel()
self.tree.setModel(self.model)
self.delegate = SettingDelegate()
self.tree.setItemDelegateForColumn(1, self.delegate)
if showSearch:
if hasattr(self.searchBox, 'setPlaceholderText'):
self.searchBox.setPlaceholderText(QApplication.translate('ConfigDialog', 'Search…'))
self.searchBox.textChanged.connect(self.textChanged)
else:
self.searchBox.hide()
self.fillTree()
self.saveMenus = False
self.tree.expanded.connect(self.itemExpanded)
self.auto_adjust_columns = True
def textChanged(self, text=None):
if text is not None:
text = str(text.lower())
else:
text = str(self.searchBox.text().lower())
found = self._filterItem(self.model.invisibleRootItem(), text)
self.auto_adjust_columns = False
if text:
self.tree.expandAll()
else:
self.tree.collapseAll()
self.adjustColumns()
self.auto_adjust_columns = True
if text:
return found
else:
self.tree.collapseAll()
return False
def _filterItem(self, item, text, forceShow=False):
if item.hasChildren():
show = forceShow or isinstance(item, QStandardItem) and bool(text) and (text in item.text().lower())
for i in range(item.rowCount()):
child = item.child(i)
show = self._filterItem(child, text, forceShow) or show
self.tree.setRowHidden(item.row(), item.index().parent(), not show)
return show
elif isinstance(item, QStandardItem):
show = forceShow or bool(text) and (text in item.text().lower())
self.tree.setRowHidden(item.row(), item.index().parent(), not show)
return show
def fillTree(self):
self.fillTreeUsingProviders()
def fillTreeUsingProviders(self):
self.items = {}
self.model.clear()
self.model.setHorizontalHeaderLabels([self.tr('Setting'),
self.tr('Value')])
settings = ProcessingConfig.getSettings()
rootItem = self.model.invisibleRootItem()
"""
Filter 'General', 'Models' and 'Scripts' items
"""
priorityKeys = [self.tr('General'), self.tr('Models'), self.tr('Scripts')]
for group in priorityKeys:
groupItem = QStandardItem(group)
icon = ProcessingConfig.getGroupIcon(group)
groupItem.setIcon(icon)
groupItem.setEditable(False)
emptyItem = QStandardItem()
emptyItem.setEditable(False)
rootItem.insertRow(0, [groupItem, emptyItem])
if not group in settings:
continue
# add menu item only if it has any search matches
for setting in settings[group]:
if setting.hidden or setting.name.startswith("MENU_"):
continue
#.........这里部分代码省略.........