slint-ui/slint · error · NotImplementedError
does not support inserting rows
Error message
{type(self).__name__} does not support inserting rows What it means
The base Model class's insert_row default implementation raises NotImplementedError because a generic model cannot insert rows. Subclasses must override insert_row (and call notify_row_added) to support insertion.
Solutions
- Use slint.ListModel, which implements insert_row/append.
- In a custom model subclass, override insert_row to insert into the backing store and call self.notify_row_added(row, 1).
- If the model is intentionally immutable, avoid calling insert_row and expose updates via property bindings instead.
Example fix
# before
class MyModel(slint.Model):
def row_count(self): return len(self.data)
# after
class MyModel(slint.Model):
def row_count(self): return len(self.data)
def insert_row(self, row, value):
self.data.insert(row, value)
self.notify_row_added(row, 1) Defensive patterns
Strategy: type-guard
Validate before calling
def supports_insert(model):
return type(model).insert_row is not slint.Model.insert_row Type guard
def supports_insert(model):
return isinstance(model, slint.ListModel) or overrides(model, "insert_row") Try / catch
try:
model.insert_row(0, item)
except NotImplementedError:
model = slint.ListModel([item] + existing) Prevention
- Use slint.ListModel when rows will be added at runtime.
- Override insert_row + notify_row_added in custom mutable models.
When it happens
Trigger: Calling model.insert_row(index, value) on a model whose class does not override insert_row.
Common situations: Subclassing slint.Model for a read-only data source and later appending items from UI logic; passing a custom minimal model to a component that adds rows.
Related errors
- does not support removing rows
- insertRow is not implemented on this model
- removeRow is not implemented on this model
- row index out of range
- setRowData is not implemented on this model
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/d80926df67e94f0a.
Report an issue: GitHub.
Appendix: source
Thrown at api/python/slint/slint/models.py:78
"""Add a new row to the model with the provided value.
The default implementation calls `insert_row` with the row count."""
self.insert_row(self.row_count(), value)
def remove_row(self, row: int) -> None:
"""Remove the row at the given index.
Raises an exception when the model rejects the modification.
The default implementation raises NotImplementedError. A model that
supports removing rows should also call `notify_row_removed`."""
raise NotImplementedError(
f"{type(self).__name__} does not support removing rows"
)
def insert_row(self, row: int, value: T) -> None:
"""Insert a new row at the given index.
Raises an exception when the model rejects the modification.
The default implementation raises NotImplementedError. A model that
supports inserting rows should also call `notify_row_added`."""
raise NotImplementedError(
f"{type(self).__name__} does not support inserting rows"
)
def notify_row_changed(self, row: int) -> None:
"""Call this method from a sub-class to notify the views that a row has changed."""
super().notify_row_changed(row)
def notify_row_removed(self, row: int, count: int) -> None:
"""Call this method from a sub-class to notify the views that
`count` rows have been removed starting at `row`."""
super().notify_row_removed(row, count)
def notify_row_added(self, row: int, count: int) -> None:
"""Call this method from a sub-class to notify the views that
`count` rows have been added starting at `row`."""
super().notify_row_added(row, count)
View on GitHub (pinned to 3a7e700487)