Python PyQt5.QtCore 模块,QAbstractItemModel() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用PyQt5.QtCore.QAbstractItemModel()

项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, parent=None, columns=None):

        if columns is not None:
            self.columns = columns

        QtCore.QAbstractItemModel.__init__(self, parent=parent)
        self.rootnode = VQTreeItem((), None)

        if self.editable is None:
            self.editable = [False, ] * len(self.columns)
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def flags(self, index):
        if not index.isValid():
            return 0
        flags = QtCore.QAbstractItemModel.flags(self, index)
        col = index.column()
        if self.editable[col]:
            flags |= QtCore.Qt.ItemIsEditable
        if self.dragable:
            flags |= QtCore.Qt.ItemIsDragEnabled
        return flags
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, rows=()):
        QtCore.QAbstractItemModel.__init__(self)
        # Make sure the rows are lists ( so we can mod them )
        self.rows = [list(row) for row in rows]
        if self.editable is None:
            self.editable = [False, ] * len(self.columns)
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def flags(self, index):
        if not index.isValid():
            return 0
        flags = QtCore.QAbstractItemModel.flags(self, index)
        col = index.column()
        if self.editable[col]:
            flags |= QtCore.Qt.ItemIsEditable

        if self.dragable:
            flags |= QtCore.Qt.ItemIsDragEnabled  # | QtCore.Qt.ItemIsDropEnabled

        return flags

        # def data(self, index, role):
        # if not index.isValid():
        # return None
        # item = index.internalPointer()
        # if role == QtCore.Qt.DisplayRole:
        # return item.data(index.column())
        # if role == QtCore.Qt.UserRole:
        # return item
        # return None

        # def _vqt_set_data(self, row, col, value):
        # return False

    # def appends(self, rows):
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def setModelData(self, editor: QCheckBox, model: QAbstractItemModel, index: QModelIndex):
        model.setData(index, editor.isChecked(), Qt.EditRole)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex):
        model.setData(index, editor.value(), Qt.EditRole)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
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)