title: Update and sort Qt ComboBoxes alphabetically
body: <p>I want to write a program, working like a little navigation system uisng the Qt framework, but i still am very new to it.</p>
  
  <p>I created a dialog with two Comboboxes. Each combobox contains all "citynames".
  At the initialization the content of both boxes is sorted alphabetically. </p>
  
  <p>If a name in the first box is selected, it should not be displayed in the second one and the other way too.</p>
  
  <p>I successfully removed the item and added it again, if another item is selected, but know i cannot sort them anymore</p>
  
  <p>This is what i tried so far for updating:</p>
  
  <pre><code>for(std::vector&lt;City&gt;::iterator iter = citylist.begin(); iter != citylist.end(); iter++){
      if(ui-&gt;combo2-&gt;currentText() != (*iter).getName()
              and ui-&gt;combo1-&gt;findText((*iter).getName()) == -1){
          ui-&gt;combo1-&gt;addItem((*iter).getName(),QComboBox::InsertAlphabetically);
      }
  }
  </code></pre>
  
  <p>but it does not insert the items alphabetically...</p>
  
  <p>so i tried to sort it afterwards:</p>
  
  <pre><code> QSortFilterProxyModel* proxy = new QSortFilterProxyModel(ui-&gt;combo1);
  
  proxy-&gt;setSourceModel(ui-&gt;combo1-&gt;model());
  
  // combo's current model must be reparented,
  // otherwise QComboBox::setModel() will delete it
  ui-&gt;combo1-&gt;model()-&gt;setParent(proxy);
  
  ui-&gt;combo1-&gt;setModel(proxy);
  
  // sort
  ui-&gt;combo1-&gt;model()-&gt;sort(0);
  </code></pre>
  
  <p>But if i try to call this function an error occurs and the application terminates.</p>
  
  <p>So is anyone out there, who is able to help me?</p>