title: toInt() function using API version 2
body: <p>I have a function using<code>QSettings</code> to load my setting. However, if I set the API to version 2, using <code>import sip</code>, <code>sip.setapi('QVariant', 2)</code>, for example, I get an error: <code>'unicode' has no attibute 'toInt()</code>. When I set it to version 1, it works fine.</p>
  
  <p>How can I convert a <code>QVariant</code> to an <code>Int</code>, when using API version 2?</p>
  
  <pre><code>def Load_Settings(self):
  
      output_folder = os.getcwd() + os.sep + 'Settings' + os.sep
      if not os.path.isdir(output_folder):
          os.mkdir(output_folder)
  
      dialog = QtGui.QFileDialog()
      file = dialog.getOpenFileName(self, 'Choose settings', output_folder, filter =".ini (*.ini *.)")
  
      saved_settings = QSettings(file, QSettings.IniFormat)
      saved_settings.beginGroup('SavedSettings')
  
      pce_threshold_spinBox = saved_settings.value('pce_threshold_spinBox').toInt()[0]
      self.pce_threshold_spinBox.setValue(pce_threshold_spinBox)
  
      info_size_comboBox = saved_settings.value('info_size_comboBox').toInt()[0]
      self.info_size_comboBox.setCurrentIndex(info_size_comboBox)
  
      comboBox = saved_settings.value('comboBox').toInt()[0]
      self.comboBox.setCurrentIndex(comboBox)
  
      matrix_name_line = saved_settings.value('matrix_name_line').toString()
      self.matrix_name_line.setText(matrix_name_line)
  
      text_adicional_info_box = saved_settings.value('text_adicional_info_box').toString()
      self.text_adicional_info_box.setText(text_adicional_info_box)
  
      enter_path_iv = saved_settings.value('enter_path_iv').toString()
      self.enter_path_iv.setText(enter_path_iv)
  
      enter_path_eqe = saved_settings.value('enter_path_eqe').toString()
      self.enter_path_eqe.setText(enter_path_eqe)
  
      for key in self.lesker_pixel_Dic.keys():
          values = saved_settings.value('s'+str(key[0])+str(key[1])+'p'+str(key[2])).toInt()[0]
          self.lesker_pixel_Dic[key].setCheckState(values)
  
  
      for key in self.sample_Dic.keys():
          samples = rowfunc(key[0], key[1], 6)
          values = saved_settings.value('s'+str(samples[0])+str(samples[1])).toString()
          if values == 'true':
              self.sample_Dic[key].setChecked(True)
          if values == 'false':
              self.sample_Dic[key].setChecked(False)
      else:
          pass
  
  
      self.boxes = self.setting_box.findChildren(QtGui.QCheckBox)
      for box, x in zip(self.boxes, range(0,10)):
          values = saved_settings.value('Box'+str(x)).toInt()[0]
          box.setCheckState(values)
  
      for key, x in zip(self.lesker_entry_Dic.keys(), range(1, 29)):
          value = saved_settings.value('info_'+str(x)).toString()
          self.lesker_entry_Dic[key].setText(value)
  
      saved_settings.endGroup()
  </code></pre>
  
  <p>I had this <a href="https://github.com/pyinstaller/pyinstaller/wiki/Recipe-PyQt4-API-Version" rel="nofollow noreferrer">problem</a>, that's why I set API to version 2, when using <code>PyInstaller</code>.</p>