當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。