slint::VectorModel Class
template <typename ModelData>class VectorModel;#include <slint.h>Inherits slint::Model
A Model backed by a SharedVector.
Public Functions
Section titled “Public Functions” VectorModel
Section titled “ VectorModel”slint::VectorModel<ModelData>::VectorModel()=default
Constructs a new empty VectorModel.
VectorModel
Section titled “ VectorModel”slint::VectorModel<ModelData>::VectorModel(std::vector<ModelData> array)
Constructs a new VectorModel from array.
row_count (virtual)
Section titled “ row_count (virtual)”size_t slint::VectorModel<ModelData>::row_count() const override
The amount of row in the model.
row_data (virtual)
Section titled “ row_data (virtual)”std::optional<ModelData> slint::VectorModel<ModelData>::row_data(size_t i) const override
Returns the data for a particular row. This function should be called with row < row_count().
set_row_data (virtual)
Section titled “ set_row_data (virtual)”void slint::VectorModel<ModelData>::set_row_data(size_t i, const ModelData &value) override
Sets the data for a particular row.
This function should only be called with row < row_count().
If the model cannot support data changes, then it is ok to do nothing. The default implementation will print a warning to stderr.
If the model can update the data, it should also call row_changed
remove_row (virtual)
Section titled “ remove_row (virtual)”bool slint::VectorModel<ModelData>::remove_row(size_t index) override
Removes the row at the given index from the model. Returns true when the row was removed, false when the model rejected it.
The default implementation does nothing and returns false. A model that supports removing rows should also call notify_row_removed.
insert_row (virtual)
Section titled “ insert_row (virtual)”bool slint::VectorModel<ModelData>::insert_row(size_t index, const ModelData &value) override
Inserts a new row with the given data at the given index, shifting the following rows by one. Returns true when the row was inserted, false when the model rejected it.
The default implementation does nothing and returns false. A model that supports inserting rows should also call notify_row_added.
push_back
Section titled “ push_back”void slint::VectorModel<ModelData>::push_back(const ModelData &value)
Append a new row with the given value.
void slint::VectorModel<ModelData>::erase(size_t index)
Remove the row at the given index from the model.
insert
Section titled “ insert”void slint::VectorModel<ModelData>::insert(size_t index, const ModelData &value)
Inserts the given value as a new row at the specified index.
void slint::VectorModel<ModelData>::clear()
Erases all rows from the VectorModel.
set_vector
Section titled “ set_vector”void slint::VectorModel<ModelData>::set_vector(std::vector<ModelData> array)
Replaces the underlying VectorModel’s vector with array.
© 2026 SixtyFPS GmbH