Python PyQt5.QtCore.QAbstractListModel() Examples
The following are 5
code examples of PyQt5.QtCore.QAbstractListModel().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtCore
, or try the search function
.
Example #1
Source File: ListModel.py From Uranium with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #2
Source File: ListModel.py From Uranium with GNU Lesser General Public License v3.0 | 5 votes |
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")]
Example #3
Source File: SettingDefinitionsModel.py From Uranium with GNU Lesser General Public License v3.0 | 5 votes |
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)
Example #4
Source File: SettingDefinitionsModel.py From Uranium with GNU Lesser General Public License v3.0 | 5 votes |
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
Example #5
Source File: SettingDefinitionsModel.py From Uranium with GNU Lesser General Public License v3.0 | 4 votes |
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