PythonListModel¶
-
class
glue.utils.qt.
PythonListModel
(items, parent=None)¶ Bases:
PyQt5.QtCore.QAbstractListModel
A Qt Model that wraps a python list, and exposes a list-like interface
This can be connected directly to multiple QListViews, which will stay in sync with the state of the container.
Create a new model
- Parameters
- itemslist
The initial list to wrap
- parentQObject
The model parent
Methods Summary
append
(self, value)data
(self, index, role)Retrieve data at each index
extend
(self, values)headerData
(self, section, orientation, role)Column labels
insert
(self, row, value)pop
(self[, row])Remove and return an item (default last item)
removeRow
(self, row[, parent])Remove a row from the table
rowCount
(self[, parent])Number of rows
row_label
(self, row)The textual label for the row
setData
(self, index, value, role)Update the data in-place
set_list
(self, values)Set the model to a new list
Methods Documentation
-
append
(self, value)¶
-
data
(self, index, role)¶ Retrieve data at each index
-
extend
(self, values)¶
-
headerData
(self, section, orientation, role)¶ Column labels
-
insert
(self, row, value)¶
-
pop
(self, row=None)¶ Remove and return an item (default last item)
- Parameters
- rowint (optional)
Which row to remove. Default=last
- Returns
- poppedobject
-
removeRow
(self, row, parent=None)¶ Remove a row from the table
- Parameters
- rowint
Row to remove
- Returns
- successfulbool
-
rowCount
(self, parent=None)¶ Number of rows
-
row_label
(self, row)¶ The textual label for the row
-
setData
(self, index, value, role)¶ Update the data in-place
- Parameters
- indexQModelIndex
The location of the change
- valueobject
The new value
- roleQEditRole
Which aspect of the model to update
-
set_list
(self, values)¶ Set the model to a new list