本文整理汇总了Python中PyQt5.QtGui.QStandardItemModel方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QStandardItemModel方法的具体用法?Python QtGui.QStandardItemModel怎么用?Python QtGui.QStandardItemModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui
的用法示例。
在下文中一共展示了QtGui.QStandardItemModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def __init__(self,
name: str,
items: typing.Iterable[_ItemType],
sort: bool = True,
delete_func: util.DeleteFuncType = None,
parent: QWidget = None):
super().__init__(parent)
self.name = name
self.srcmodel = QStandardItemModel(parent=self)
self._pattern = ''
# ListCategory filters all columns
self.columns_to_filter = [0, 1, 2]
self.setFilterKeyColumn(-1)
for item in items:
self.srcmodel.appendRow([QStandardItem(x) for x in item])
self.setSourceModel(self.srcmodel)
self.delete_func = delete_func
self._sort = sort
示例2: populate
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def populate(self):
self.setFeatures(QtWidgets.QDockWidget.DockWidgetClosable)
self.setTitleBarWidget(QtWidgets.QWidget(self)) # Removes titlebar
self.sideDockTabWidget = QtWidgets.QTabWidget(self)
self.setWidget(self.sideDockTabWidget)
# This order is important
self.bookmarkModel = QtGui.QStandardItemModel(self)
self.bookmarkProxyModel = BookmarkProxyModel(self)
self.bookmarks = Bookmarks(self)
self.bookmarks.generate_bookmark_model()
if not self.parent.are_we_doing_images_only:
self.annotationModel = QtGui.QStandardItemModel(self)
self.annotations = Annotations(self)
self.annotations.generate_annotation_model()
self.searchResultsModel = QtGui.QStandardItemModel(self)
self.search = Search(self)
示例3: populateUI
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def populateUI(self):
self.availableObjectsList.addItems(Detector.getDefaultAvailableObjects())
for sourceMode in self.__sourceModes:
self.sourceCBox.addItem(sourceMode)
for displayMode in self.__displayModes:
self.displayCBox.addItem(displayMode)
for shapeMode in self.__shapeModes:
self.shapeCBox.addItem(shapeMode)
for fillMode in self.__fillModes:
self.fillCBox.addItem(fillMode)
for bgMode in self.__bgModes:
self.bgCBox.addItem(bgMode)
model = QtGui.QStandardItemModel(self)
func = lambda node, parent: self.populateTree(node, parent)
Detector.getDefaultObjectsTree().map(model, func)
self.objectsTree.setModel(model)
示例4: _model_builder
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def _model_builder(self, model, data, initialize=False):
'''
Build the function model.
@param model: QStandardItemModel object
'''
if initialize:
model.clear() # Clear the model
FIRSTUI.SharedObjects.make_model_headers(model)
if not data:
return
model.add_data(data)
# Add db functions to the model
root_node = model.invisibleRootItem()
for address, matches in data.iteritems():
function = FIRST.Metadata.get_function(address)
func_row = self._make_function_item(function, len(matches))
root_node.appendRow(func_row)
for match in matches:
info_list = FIRSTUI.SharedObjects.make_match_info(match)
func_row[0].appendRow(info_list)
示例5: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def __init__(self):
super(QtWidgets.QTreeView, self).__init__()
# self.__typeWidgets = {}
# self.__typeWrappers = {}
model = QtGui.QStandardItemModel(0, 1)
model.setHorizontalHeaderLabels(
["Name", "Value", "Unit", "Class", "Description"]
)
self.rootNode = model.invisibleRootItem()
self.setModel(model)
self.setColumnWidth(0, 150)
self.setAlternatingRowColors(True)
示例6: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def __init__(self, view):
QObject.__init__(self, view)
self.view = view
self.model = QStandardItemModel()
self.view.setModel(self.model)
self.nodesets = []
self.server_mgr = None
self.view.header().setSectionResizeMode(1)
addNodeSetAction = QAction("Add Reference Node Set", self.model)
addNodeSetAction.triggered.connect(self.add_nodeset)
self.removeNodeSetAction = QAction("Remove Reference Node Set", self.model)
self.removeNodeSetAction.triggered.connect(self.remove_nodeset)
self.view.setContextMenuPolicy(Qt.CustomContextMenu)
self.view.customContextMenuRequested.connect(self.showContextMenu)
self._contextMenu = QMenu()
self._contextMenu.addAction(addNodeSetAction)
self._contextMenu.addAction(self.removeNodeSetAction)
示例7: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def __init__(self, view):
QObject.__init__(self, view)
self.view = view
self.model = QStandardItemModel()
self.view.setModel(self.model)
delegate = MyDelegate(self.view, self)
delegate.error.connect(self.error.emit)
self.view.setItemDelegate(delegate)
self.node = None
self.view.header().setSectionResizeMode(1)
self.addNamespaceAction = QAction("Add Namespace", self.model)
self.addNamespaceAction.triggered.connect(self.add_namespace)
self.removeNamespaceAction = QAction("Remove Namespace", self.model)
self.removeNamespaceAction.triggered.connect(self.remove_namespace)
self.view.setContextMenuPolicy(Qt.CustomContextMenu)
self.view.customContextMenuRequested.connect(self.showContextMenu)
self._contextMenu = QMenu()
self._contextMenu.addAction(self.addNamespaceAction)
self._contextMenu.addAction(self.removeNamespaceAction)
示例8: _model_builder
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def _model_builder(self, model):
"""
Build the function model.
@param model: QStandardItemModel object
"""
model.clear() # Clear the model
root_node = model.invisibleRootItem()
model.setHorizontalHeaderLabels(("Type", "Score", "Value", "Description", "Raw Value"))
if self.die_db is None:
return
value_list = self.die_db.get_all_values()
for value in value_list:
value_data_item_list = self._make_value_item(value)
root_node.appendRow(value_data_item_list)
示例9: init_disk_ui
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def init_disk_ui(self):
self.model_disk = QStandardItemModel(1, 3)
self.config_tableview("disk")
self.btn_disk_delete.setIcon(QIcon(SRC_DIR + "delete.ico"))
self.btn_disk_dl.setIcon(QIcon(SRC_DIR + "downloader.ico"))
self.btn_disk_select_all.setIcon(QIcon(SRC_DIR + "select_all.ico"))
self.btn_disk_select_all.setToolTip("按下 Ctrl/Alt + A 全选或则取消全选")
self.btn_disk_select_all.clicked.connect(lambda: self.select_all_btn("reverse"))
self.table_disk.clicked.connect(lambda: self.select_all_btn("cancel"))
self.btn_disk_dl.clicked.connect(lambda: self.call_multi_manipulator("download"))
self.btn_disk_mkdir.setIcon(QIcon(SRC_DIR + "add_folder.ico"))
self.btn_disk_mkdir.clicked.connect(self.call_mkdir)
self.btn_disk_delete.clicked.connect(self.call_remove_files)
# 文件拖拽上传
self.table_disk.drop_files.connect(self.show_upload_dialog)
self.table_disk.doubleClicked.connect(self.change_dir)
# rec tab
示例10: init_rec_ui
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def init_rec_ui(self):
"""回收站ui初始化"""
self.model_rec = QStandardItemModel(1, 3)
self.config_tableview("rec")
self.table_rec.doubleClicked.connect(self.call_rec_folder_dialog)
self.btn_rec_select_all.setIcon(QIcon(SRC_DIR + "select_all.ico"))
self.btn_rec_select_all.clicked.connect(lambda: self.select_all_btn("reverse"))
self.btn_rec_delete.clicked.connect(lambda: self.call_multi_manipulator("delete"))
self.btn_rec_delete.setIcon(QIcon(SRC_DIR + "delete.ico"))
self.btn_recovery.clicked.connect(lambda: self.call_multi_manipulator("recovery"))
self.btn_recovery.setIcon(QIcon(SRC_DIR + "rec_folder.ico"))
self.btn_rec_delete.setToolTip("彻底删除选中文件(夹)")
self.btn_recovery.setToolTip("恢复选中文件(夹)")
self.btn_recovery_all.clicked.connect(lambda: self.call_multi_manipulator("recovery_all"))
self.btn_recovery_all.setIcon(QIcon(SRC_DIR + "rec_folder.ico"))
self.btn_recovery_all.setToolTip("恢复全部")
self.btn_rec_clean.clicked.connect(lambda: self.call_multi_manipulator("clean"))
self.btn_rec_clean.setIcon(QIcon(SRC_DIR + "rec_bin.ico"))
self.btn_rec_clean.setToolTip("清理回收站全部")
self.btn_rec_expire_files.setToolTip("暂时无效!")
# shared url
示例11: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def __init__(self, colors, *args, **kwargs):
super(CColorItems, self).__init__(*args, **kwargs)
self.setItemDelegate(StyledItemDelegate(self))
self.setEditTriggers(self.NoEditTriggers)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setFlow(self.LeftToRight)
self.setWrapping(True)
self.setResizeMode(self.Adjust)
self.setSpacing(6)
self.setCursor(Qt.PointingHandCursor)
self.setFrameShape(self.NoFrame)
self._model = QStandardItemModel(self)
self.setModel(self._model)
for color in colors:
self.addColor(color)
示例12: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def __init__(self, parent=None, file_path=None):
super().__init__(parent=parent)
h_box = QHBoxLayout(self)
self._ident_titles = ['EI_MAG0', 'EI_MAG1', 'EI_MAG2', 'EI_MAG3', 'EI_CLASS', 'EI_DATA', 'EI_VERSION', 'EI_OSABI', 'EI_ABIVERSION', 'EI_PAD']
self.elf_info = DwarfListView(self)
self.elf_info.setRootIsDecorated(True)
self.elf_info.setExpandsOnDoubleClick(True)
self.elf_info.setContextMenuPolicy(Qt.CustomContextMenu)
self.elf_info.customContextMenuRequested.connect(self._on_context_menu)
h_box.addWidget(self.elf_info)
self._elf_info_mdl = QStandardItemModel(0, 2)
self._elf_info_mdl.setHeaderData(0, Qt.Horizontal, 'Name')
self._elf_info_mdl.setHeaderData(1, Qt.Horizontal, 'Value')
self.elf_info.setModel(self._elf_info_mdl)
self.elf_info.doubleClicked.connect(self._on_dblclicked)
self.title = "ELF Info"
self._elf_file_path = None
self.setLayout(h_box)
if file_path:
self.set_elf_file(file_path)
示例13: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def __init__(self, *args, **kwargs):
super(ListView, self).__init__(*args, **kwargs)
# 模型
self._model = QStandardItemModel(self)
self.setModel(self._model)
# 循环生成10个自定义控件
for i in range(10):
item = QStandardItem()
self._model.appendRow(item) # 添加item
# 得到索引
index = self._model.indexFromItem(item)
widget = CustomWidget(str(i))
item.setSizeHint(widget.sizeHint()) # 主要是调整item的高度
# 设置自定义的widget
self.setIndexWidget(index, widget)
示例14: data
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def data(self, index, role=QtCore.Qt.DisplayRole):
if role == QtCore.Qt.DisplayRole:
dstr = QtGui.QStandardItemModel.data(self, index, role)
if dstr == "" or dstr is None:
if isinstance(self.type, click.types.Tuple):
row = index.row()
if 0 <= row < len(self.type.types):
tp = self.type.types[row]
dstr = tp.name
else:
dstr = self.type.name
return dstr
if role == _GTypeRole:
tp = click.STRING
if isinstance(self.type, click.types.Tuple):
row = index.row()
if 0 <= row < len(self.type.types):
tp = self.type.types[row]
elif isinstance(self.type, click.types.ParamType):
tp = self.type
return tp
return QtGui.QStandardItemModel.data(self, index, role)
示例15: init_listVIew
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QStandardItemModel [as 别名]
def init_listVIew(self):
self.listView.setViewMode(QListView.ListMode)#或者使用QListView.IconMode QListView.ListMode
#self.listView.setMovement(QListView.Static)
self.listView.setIconSize(QSize(20,20))#图标的大小(原始图标大小如果100,100,此时设置草果原始大小则失效)
self.listView.setGridSize(QSize(60,40))#每个选项所在网格大小(每个选项外层grid宽高)
#self.listView.setMaximumHeight(200)#listView整体最大高度
#self.listView.setMinimumSize(QSize(200,200))#listView最小面积(一般如果设置最大高和宽属性后就不设置这个属性了)
#self.listView.setMaximumSize(QSize(500,500))#listVIew最大面积(一般如果设置最大高和宽属性后就不设置这个属性了)
self.listView.setMinimumHeight(80)#listView最小高度
self.listView.setResizeMode(QListView.Adjust)
#self.listView.setMovement(QListView.Static)#设置图标可不可以移动,默认是可移动的,但可以改成静态的:
self.listView_model=QStandardItemModel()
self.listView.setModel(self.listView_model)
self.listView.clicked.connect(self.checkItem)