PythonListModel#

class glue_qt.utils.PythonListModel(items, parent=None)#

Bases: 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(value)

data(index, role)

Retrieve data at each index

extend(values)

headerData(section, orientation, role)

Column labels

insert(row, value)

pop([row])

Remove and return an item (default last item)

removeRow(row[, parent])

Remove a row from the table

rowCount([parent])

Number of rows

row_label(row)

The textual label for the row

setData(index, value, role)

Update the data in-place

set_list(values)

Set the model to a new list

Methods Documentation

append(value)#
data(index, role)#

Retrieve data at each index

extend(values)#
headerData(section, orientation, role)#

Column labels

insert(row, value)#
pop(row=None)#

Remove and return an item (default last item)

Parameters:
rowint (optional)

Which row to remove. Default=last

Returns:
poppedobject
removeRow(row, parent=None)#

Remove a row from the table

Parameters:
rowint

Row to remove

Returns:
successfulbool
rowCount(parent=None)#

Number of rows

row_label(row)#

The textual label for the row

setData(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(values)#

Set the model to a new list