mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-28 12:54:45 +00:00
C++: put a pointer to the parent in the component
This commit is contained in:
parent
f35c12aef1
commit
967a2b94eb
2 changed files with 22 additions and 7 deletions
|
@ -119,12 +119,14 @@ template<typename C>
|
|||
struct Repeater {
|
||||
std::vector<std::unique_ptr<C>> data;
|
||||
|
||||
void update_model(Model *model)
|
||||
template<typename Parent>
|
||||
void update_model(Model *model, Parent *parent)
|
||||
{
|
||||
data.clear();
|
||||
auto count = model->count();
|
||||
for (auto i = 0; i < count; ++i) {
|
||||
auto x = std::make_unique<C>();
|
||||
x->parent = parent;
|
||||
x->update_data(i, model->get(i));
|
||||
data.push_back(std::move(x));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue