本文整理汇总了Python中PyQt5.QtGui.QStandardItem.setSelectable方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setSelectable方法的具体用法?Python QStandardItem.setSelectable怎么用?Python QStandardItem.setSelectable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QStandardItem
的用法示例。
在下文中一共展示了QStandardItem.setSelectable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUi
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setSelectable [as 别名]
def initUi(self, options, enabledOptions, headerOptions, singleSelectionMode):
boldFont = QFont()
boldFont.setBold(True)
# set the selection mode
if not singleSelectionMode:
self.listView_options.setSelectionMode(QAbstractItemView.ExtendedSelection)
# create enableItems if none
if enabledOptions is None:
enabledOptions = [True for idx in range(len(options))]
# Insert the choices
self.standaredItemModel = QStandardItemModel(self.listView_options)
self.standaredItemModel.itemChanged.connect(self.onItemChanged)
for idx in range(len(options)):
standaredItem = QStandardItem(options[idx])
standaredItem.setSelectable(enabledOptions[idx])
if idx in headerOptions:
standaredItem.setFont(boldFont)
self.standaredItemModel.appendRow(standaredItem)
self.listView_options.setModel(self.standaredItemModel)
# disable select all / de select all buttons if in single selection
# mode
if singleSelectionMode:
self.pushButton_sellectAll.setDisabled(True)
self.pushButton_deSellectAll.setDisabled(True)
示例2: fill_tree
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setSelectable [as 别名]
def fill_tree(self, children: List[FsFileInfo]) -> None:
self.item.removeRows(0, self.item.rowCount())
for child in self.tree.sort_children(children):
subitem = QStandardItem(child.get_label())
if child.checkable():
subitem.setCheckable(True)
subitem.setCheckState(True)
subitem.setTristate(True)
subitem.setCheckState(child.state)
subitem.setEnabled(child.enable())
subitem.setSelectable(child.selectable())
subitem.setEditable(False)
subitem.setData(QVariant(child), Qt.UserRole)
if child.folderish():
# Add "Loading..." entry in advance for when the user
# will click to expand it.
loaditem = QStandardItem(Translator.get("LOADING"))
loaditem.setSelectable(False)
subitem.appendRow(loaditem)
self.item.appendRow(subitem)