当前位置: 首页>>代码示例>>Python>>正文


Python QtCore.QAbstractItemModel方法代码示例

本文整理汇总了Python中PyQt5.QtCore.QAbstractItemModel方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QAbstractItemModel方法的具体用法?Python QtCore.QAbstractItemModel怎么用?Python QtCore.QAbstractItemModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore的用法示例。


在下文中一共展示了QtCore.QAbstractItemModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: data

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def data(self, index, role=Qt.DisplayRole):
        """Return the item data for index.

        Override QAbstractItemModel::data.

        Args:
            index: The QModelIndex to get item flags for.

        Return: The item data, or None on an invalid index.
        """
        if role != Qt.DisplayRole:
            return None
        cat = self._cat_from_idx(index)
        if cat:
            # category header
            if index.column() == 0:
                return self._categories[index.row()].name
            return None
        # item
        cat = self._cat_from_idx(index.parent())
        if not cat:
            return None
        idx = cat.index(index.row(), index.column())
        return cat.data(idx) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:26,代码来源:completionmodel.py

示例2: flags

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def flags(self, index):
        """Return the item flags for index.

        Override QAbstractItemModel::flags.

        Return: The item flags, or Qt.NoItemFlags on error.
        """
        if not index.isValid():
            return Qt.NoItemFlags
        if index.parent().isValid():
            # item
            return (Qt.ItemIsEnabled | Qt.ItemIsSelectable |
                    Qt.ItemNeverHasChildren)
        else:
            # category
            return Qt.NoItemFlags 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:18,代码来源:completionmodel.py

示例3: index

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def index(self, row, col, parent=QModelIndex()):
        """Get an index into the model.

        Override QAbstractItemModel::index.

        Return: A QModelIndex.
        """
        if (row < 0 or row >= self.rowCount(parent) or
                col < 0 or col >= self.columnCount(parent)):
            return QModelIndex()
        if parent.isValid():
            if parent.column() != 0:
                return QModelIndex()
            # store a pointer to the parent category in internalPointer
            return self.createIndex(row, col, self._categories[parent.row()])
        return self.createIndex(row, col, None) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:18,代码来源:completionmodel.py

示例4: __init__

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def __init__(self, *, column_widths=(30, 70, 0), parent=None):
        super().__init__(parent)
        self.column_widths = column_widths
        self._categories = [
        ]  # type: typing.MutableSequence[QAbstractItemModel] 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:7,代码来源:completionmodel.py

示例5: parent

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def parent(self, index):
        """Get an index to the parent of the given index.

        Override QAbstractItemModel::parent.

        Args:
            index: The QModelIndex to get the parent index for.
        """
        parent_cat = index.internalPointer()
        if not parent_cat:
            # categories have no parent
            return QModelIndex()
        row = self._categories.index(parent_cat)
        return self.createIndex(row, 0, None) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:16,代码来源:completionmodel.py

示例6: columnCount

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def columnCount(self, parent=QModelIndex()):
        """Override QAbstractItemModel::columnCount."""
        # pylint: disable=unused-argument
        return 3 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:6,代码来源:completionmodel.py

示例7: setModelData

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def setModelData(self, editor: QWidget, model: QAbstractItemModel,
                     qindex: QModelIndex):
        if isinstance(editor, QComboBox):
            value = editor.currentData(Qt.UserRole)
            model.setData(qindex, value, Qt.EditRole)
        else:
            super().setModelData(editor, model, qindex) 
开发者ID:fre-sch,项目名称:mhw_armor_edit,代码行数:9,代码来源:utils.py

示例8: __init__

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def __init__(self, columns):
        QtCore.QAbstractItemModel.__init__(self)
        self._root = CustomNode(list(itertools.repeat("", len(columns))))
        self.signals = CustomModelSignals()
        self._columns = columns 
开发者ID:haruiz,项目名称:CvStudio,代码行数:7,代码来源:treeview_model.py

示例9: parent

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def parent(self, in_index: QModelIndex = None):
        if in_index.isValid():
            parent = in_index.internalPointer().parent
            if parent:
                return QtCore.QAbstractItemModel.createIndex(self, parent.row, 0, parent)
        return QtCore.QModelIndex() 
开发者ID:haruiz,项目名称:CvStudio,代码行数:8,代码来源:treeview_model.py

示例10: index

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def index(self, row: int, column: int, parent=None, *args, **kwargs):
        if not parent or not parent.isValid():
            parent_node = self._root
        else:
            parent_node = parent.internalPointer()

        if not QtCore.QAbstractItemModel.hasIndex(self, row, column, parent):
            return QtCore.QModelIndex()
        child = parent_node.child(row)
        if child:
            return QtCore.QAbstractItemModel.createIndex(self, row, column, child)
        else:
            return QtCore.QModelIndex() 
开发者ID:haruiz,项目名称:CvStudio,代码行数:15,代码来源:treeview_model.py

示例11: setModelData

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def setModelData(self, editor: QCheckBox, model: QAbstractItemModel, index: QModelIndex):
        model.setData(index, editor.isChecked(), Qt.EditRole) 
开发者ID:jopohl,项目名称:urh,代码行数:4,代码来源:CheckBoxDelegate.py

示例12: setModelData

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
        if isinstance(editor, ExternalProgramWidget):
            model.setData(index, editor.line_edit_external_program.text(), Qt.EditRole)
        elif isinstance(editor, RandomValueWidget):
            model.setData(index, [editor.spinbox_random_min.value(), editor.spinbox_random_max.value()], Qt.EditRole)
        else:
            super().setModelData(editor, model, index) 
开发者ID:jopohl,项目名称:urh,代码行数:9,代码来源:ProtocolValueDelegate.py

示例13: setModelData

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
        if self.return_index:
            model.setData(index, editor.currentIndex(), Qt.EditRole)
        else:
            model.setData(index, editor.currentText(), Qt.EditRole) 
开发者ID:jopohl,项目名称:urh,代码行数:7,代码来源:ComboBoxDelegate.py

示例14: setModelData

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
        model.setData(index, editor.value(), Qt.EditRole) 
开发者ID:jopohl,项目名称:urh,代码行数:4,代码来源:SpinBoxDelegate.py

示例15: setModelData

# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QAbstractItemModel [as 别名]
def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
        model.setData(index, editor.currentText(), Qt.EditRole) 
开发者ID:jopohl,项目名称:urh,代码行数:4,代码来源:SectionComboBoxDelegate.py


注:本文中的PyQt5.QtCore.QAbstractItemModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。