title: PyQt: How to change currentIndex in QComboBox when custom QAbstractListModel data changed
body: <p>I've read some examples on how to define a custom model for a <code>QComboBox</code> widget.</p>
  
  <p>Here's how I defined my model:</p>
  
  <pre><code>class LevelListModel(QAbstractListModel):
      def __init__(self, parent=None, *args):
          """ datain: a list where each item is a row
          """
          QAbstractListModel.__init__(self, parent, *args)
          self.levelList = []
      def rowCount(self, parent=QModelIndex()):
          return len(self.levelList)
  
      def data(self, index, role):
          if index.isValid() and role == Qt.DisplayRole:
              return QVariant(index.row())
          else:
              return QVariant()
      def addLevel(self,level):
          self.beginResetModel()
          self.levelList.append(level)
          self.endResetModel()
  </code></pre>
  
  <p>I set the model to my <code>QComboBox</code>:</p>
  
  <pre><code>self.levelListModel = LevelListModel()
  self.ui.levelComboBox.setModel(self.levelListModel)
  </code></pre>
  
  <p>I add a model to my list this way:</p>
  
  <pre><code>newLevel = Level (self.levelListModel.rowCount() + 1)
  self.levelListModel.addLevel(newLevel)
  </code></pre>
  
  <p>The item is added correctly and I can see it inside the combobox, but I would like to change the currentIndex to be the new item's index.</p>
  
  <p>I guess <code>QAbstractListModel</code> could raise some kind of events that <code>QComboBox</code> can listen to, but I haven't still found how to do that.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>How can I notify the <code>QComboBox</code> that model data changed, and listen to that event to modify currentIndex accordingly?</li>
  <li>I used <code>[begin|end]ResetModel</code> because my entry should be an ordered sequence of integer. So I need to rebuild the data list completely once an item in the middle of the list have been removed. I don't know if this is the right way to go. Any better solution?</li>
  </ol>