Such model is very inefficient because you can only iterate it as a sequence. You could store the data in a QHash and reimplement QAbstractItemModel::match() or provide your own method for searching. Alternatively if keys are unique, store them in a private QSet object and provide a contains() method for your model.

Also, if you can make sure your keys are always sorted, you can use binary search to find the key quickly in the standard model.

So you see there are many ways to solve your problem - pick one that suits you best.