Combination of List and Hash in Qt
===

I need a data structure in which each element has a specific index but can also be retrieved using a key. 

I need that data structure for model-view Programming in Qt. 
On the one hand, the View asks for an element in a specific rows.
On the other hand, the model wants to insert and modify elements with a given key. 
Both operations should run in O(1). 

Here is an example of what I want:

The View sees the following:

    list[0]: "Alice", aged 22
    list[1]: "Carol", aged 15
    list[2]: "Bob", aged 23

The Model sees:

    hash["Alice"]: "Alice", aged 22
    hash["Bob"]: "Bob", aged 23
    hash["Carol"]: "Carol", aged 15

My idea was the following: I have a `QList<Value>` and a `QHash<Key, Value*>`. 
This is the code to insert/edit values:

    if (hash.contains(key))
        *hash[key] = value;
    else
    {
        int i = list.size();
        list << value;
        hash[key] = &list[i];
    }

The problem is that this code does not always work. 
Sometimes it works as expected, but it happens that the data structure is not consistent any more.  
I suspect, it is because QList moves it's content through memory because it allocates new space or something like that. 

As you can see, inserting and modifying values using the corresponding key runs in O(1). 
Also lookup using either index or key also runs in O(1). 
These are the operations that are important to me.

My two questions are:

 - Is there any data structure which does what I want?
 - If there is not, how could I fix this or is there a better approach?