slint-ui/slint · error · TypeError
setRowData is not implemented on this model
Error message
setRowData is not implemented on this model
What it means
Base Model's default setRowData throws because a generic model has no way to store data; subclasses must override it to support mutation. The runtime calls this when .slint code assigns to a model row. Throwing rejects the modification loudly instead of silently dropping it.
Solutions
- Override setRowData(row, data) in your Model subclass to persist the new value.
- If the model must be read-only, change the .slint usage so rows are not assigned to.
- Switch to ReadOnlyModel/ArrayModel, which implements setRowData over its backing array.
Example fix
// before
class MyModel extends slint.Model { rowCount() { return 1; } rowData(i) { return 'x'; } }
// after
class MyModel extends slint.Model {
rowCount() { return 1; }
rowData(i) { return 'x'; }
setRowData(row, data) { this.data[row] = data; }
} Defensive patterns
Strategy: try-catch
Validate before calling
if (model.setRowData === slint.Model.prototype.setRowData) throw new Error('model is read-only'); Type guard
function isEditableModel<T>(m: slint.Model<T>): boolean {
return m.setRowData !== slint.Model.prototype.setRowData;
} Try / catch
try {
model.setRowData(row, value);
} catch (e) {
if (e instanceof TypeError && /setRowData is not implemented/.test(e.message)) {
console.warn('model is read-only; change ignored');
} else throw e;
} Prevention
- Override setRowData whenever a custom model backs editable UI elements.
- Prefer ReadOnlyModel/ArrayModel over hand-rolled Model subclasses.
- Document read-only models in your component API.
When it happens
Trigger: Slint code (e.g. property assignment on a model row) or JS code calls setRowData(row, data) on a model instance that did not override setRowData.
Common situations: Using a read-only custom Model subclass in an editable context (text input bound to model data), forgetting to implement setRowData when making a model two-way editable.
Related errors
- insertRow is not implemented on this model
- removeRow is not implemented on this model
- row index is out of bounds
- does not support inserting rows
- does not support removing rows
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/bb3a8a1d4ad0ef10.
Report an issue: GitHub.
Appendix: source
Thrown at api/node/typescript/models.ts:134
* Implementations of this function must return the current number of rows.
*/
abstract rowCount(): number;
/**
* Implementations of this function must return the data at the specified row.
* @param row index in range 0..(rowCount() - 1).
* @returns undefined if row is out of range otherwise the data.
*/
abstract rowData(row: number): T | undefined;
/**
* Implementations of this function must store the provided data parameter
* in the model at the specified row.
* The default implementation throws, rejecting the modification.
* @param _row index in range 0..(rowCount() - 1).
* @param _data new data item to store on the given row index
*/
setRowData(_row: number, _data: T): void {
throw new TypeError("setRowData is not implemented on this model");
}
/**
* Adds a line to the model with the provided data.
* Throws when the model rejects the modification.
* The default implementation calls {@link Model.insertRow} with the row count.
* @param data new data item to store in a new row.
*/
pushRow(data: T): void {
this.insertRow(this.rowCount(), data);
}
/**
* Implementations of this function must remove the row at the specified index.
* Throws when the model rejects the modification; the default implementation
* always throws.
* @param _index index of the row to remove.
*/View on GitHub (pinned to bb937076de)