title: Proper way to modify Qt data structures using foreach loop
body: <p>I am iterating through a <code>QLinkedList</code> using a <code>foreach</code> loop, but I need to delete items if they match a certain condition.  What is the proper way to do this without messing up the loop?</p>
  
  <pre><code>foreach( Object obj, myLinkedList )
  {
      if( obj.val == BAD_VAL )
          // remove the item from myLinkedList
  }
  </code></pre>
  
  <p>I have found <a href="https://stackoverflow.com/q/8613737/2062384">other questions</a> that sort of address this, but not for the general case such as the linked list.</p>
  
  <p>I would like to know also concerning other data structures (like <code>QSet</code>, <code>QHash</code>, etc.) if possible.  Thanks</p>