Skip to content

slint::ReverseModel Class

template <typename ModelData>
class ReverseModel;
C++
#include <slint.h>
C++

Inherits slint::Model< ModelData >.

The ReverseModel acts as an adapter model for a given source model by reserving all rows. This means that the first row in the source model is the last row of this model, the second row is the second last, and so on.

auto source_model = std::make_shared<slint::VectorModel<int>>(
// std::vector<int> { 1, 2, 3, 4, 5 });
auto reversed_model = std::make_shared<slint::ReverseModel<int>>(source_model);
C++
slint::ReverseModel< ModelData >::ReverseModel(std::shared_ptr< Model< ModelData > > source_model)

Constructs a new ReverseModel that provides a reversed view on the source_model.

size_t slint::ReverseModel< ModelData >::row_count() const override

The amount of row in the model.

std::optional< ModelData > slint::ReverseModel< ModelData >::row_data(size_t i) const override

Returns the data for a particular row. This function should be called with row < row_count().

void slint::ReverseModel< 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

std::shared_ptr< Model< ModelData > > slint::ReverseModel< ModelData >::source_model() const

Returns the source model of this reserve model.


© 2026 SixtyFPS GmbH