title: How to remove values from a QMap?
body: <p>Suppose I want to remove items according to some criterium. Let's say:</p>
  
  <pre><code>QMap&lt;int, int&gt; map;
  </code></pre>
  
  <p>and I want to remove all the items where value is an odd number. If I use an iterator:</p>
  
  <pre><code>for (auto it = map.begin(); it != map.end(); ++it)
      if (it.value() % 2 == 1)
          map.remove(it.key());
  </code></pre>
  
  <p>This code is probably wrong, since the call of </p>
  
  <pre><code>map.remove(it.key()) 
  </code></pre>
  
  <p>invalidates the iterator. How can I do this without reseting the iterator after each removal?</p>