[Development] Renaming QGenericItemModel

Richard Gustavsen Richard.Gustavsen at qt.io
Tue May 20 10:26:24 CEST 2025


> 
> I would like to come up with some C++ template class that gives type-safe access to the model while also respecting QAIM requirements, but doesn’t require any usage of QModelIndex, role values etc. I suspect that “Adaptor” will be a good term to use for such a class. Something along the lines of:
> 
> 
> std::vector<int> data;
> QRangeItemModelAdaptor adaptor(data);
> view.setModel(adaptor.model());
> 
>> 
> adaptor.erase(adaptor.begin());
> adaptor[0] = x;
> adaptor.push_back(y);
> 

Would it be more convenient to put the range API directly on QRangeModel instead? E.g:

QRangeModel model({1, 2, 3, 4, 5});
listView.setModel(&model);
model.erase(model.begin());
model[0] = x;
model.push_back(y);

-Richard


More information about the Development mailing list