當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QAbstractListModel方法代碼示例

本文整理匯總了Python中PyQt5.QtCore.QAbstractListModel方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QAbstractListModel方法的具體用法?Python QtCore.QAbstractListModel怎麽用?Python QtCore.QAbstractListModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtCore的用法示例。


在下文中一共展示了QtCore.QAbstractListModel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: rowCount

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QAbstractListModel [as 別名]
def rowCount(self, parent = None) -> int:
        """This function is necessary because it is abstract in QAbstractListModel.

        Under the hood, Qt will call this function when it needs to know how
        many items are in the model.
        This pyqtSlot will not be linked to the itemsChanged signal, so please
        use the normal count() function instead.
        """

        return self.count 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:12,代碼來源:ListModel.py

示例2: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QAbstractListModel [as 別名]
def data(self, index, role):
        """Reimplemented from QAbstractListModel"""

        if not index.isValid():
            return QVariant()
        return self._items[index.row()][self._role_names[role].decode("utf-8")] 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:8,代碼來源:ListModel.py

示例3: count

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QAbstractListModel [as 別名]
def count(self) -> int:
        """Reimplemented from QAbstractListModel

        Note that count() is overridden from QAbstractItemModel. The signature
        of the method in that class is "int count()" which makes this slot
        declaration incorrect.
        TODO: fix the pointer when actually using this parameter.
        """

        if not self._container:
            return 0

        return len(self._row_index_list) 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:15,代碼來源:SettingDefinitionsModel.py

示例4: rowCount

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QAbstractListModel [as 別名]
def rowCount(self, parent = None) -> int:
        """This function is necessary because it is abstract in QAbstractListModel.

        Under the hood, Qt will call this function when it needs to know how many items are in the model.
        This pyqtSlot will not be linked to the itemsChanged signal, so please use the normal count() function instead.
        """

        return self.count 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:10,代碼來源:SettingDefinitionsModel.py

示例5: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QAbstractListModel [as 別名]
def data(self, index, role):
        """Reimplemented from QAbstractListModel"""

        if not self._container:
            return QVariant()

        if not index.isValid():
            return QVariant()

        if role not in self._role_names:
            return QVariant()

        try:
            definition = self._definition_list[self._row_index_list[index.row()]]
        except IndexError:
            # Definition is not visible or completely not in the list
            return QVariant()

        if role == self.KeyRole:
            return definition.key
        elif role == self.DepthRole:
            return len(definition.getAncestors())
        elif role == self.VisibleRole:
            return definition.key in self._visible
        elif role == self.ExpandedRole:
            return definition.key in self._expanded

        role_name = self._role_names[role]
        try:
            data = getattr(definition, role_name.decode())
        except AttributeError:
            data = ""

        if isinstance(data, collections.OrderedDict):
            result = []
            for key, value in data.items():
                if self._i18n_catalog:
                    value = self._i18n_catalog.i18nc(definition.key + " option " + key, value)

                result.append({"key": key, "value": value})
            return result

        if isinstance(data, str) and self._i18n_catalog:
            data = self._i18n_catalog.i18nc(definition.key + " " + role_name.decode(), data)

        return data 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:48,代碼來源:SettingDefinitionsModel.py


注:本文中的PyQt5.QtCore.QAbstractListModel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。