title: Saving states of QRadioButtons using QSettings not persisting values correctly in PyQt5
body: <p>I'm baffled by the results of using QSettings to save the state of my radio buttons from one app session to another using PyQt5. (OS = Ubuntu Linux 18.04)</p>
  <p>These are the steps to produce baffling results:</p>
  <ol>
  <li>Run the app; see both radio buttons selected; both buttons fire as if mouse selected</li>
  <li>Deselect the top radio button</li>
  <li>Close the app; see the 'correct' saving of the radio button checked states</li>
  <li>Run the app; both radio buttons are selected even though different states were saved where only one button is selected</li>
  <li>Deselect the top radio button</li>
  <li>Close the app; see the 'correct' saving of the radio button checked states</li>
  <li>In the code, in line 18, change <code>QSettings('LoneProgrammer2', 'qsettingsTest1')</code> to <code>QSettings('ChangeThis', 'qsettingsTest1')</code>; save the code</li>
  <li>Run the app; !!The correct saved values are reflected by the radio button selection!!</li>
  <li>Close the app;
  10 Run the app and now there are two radio buttons selected again!</li>
  </ol>
  <p>Can anyone please explain what's going on here?  I just want the QSettings to work.</p>
  <pre><code>import sys
  
  from PyQt5.QtCore import QSettings
  from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QDialogButtonBox, QGroupBox, QHBoxLayout, QRadioButton
  
  
  class MyApp(QWidget):
      def __init__(self):
          super().__init__()
  
          self.oAutoPromoteRadioBtn = QRadioButton(&quot;Automatically Promote to Queen&quot;)
          self.oAutoPromoteRadioBtn.toggled.connect(self.on_selected)
  
          self.oUsePopupRadioBtn = QRadioButton(&quot;Promote Pawn Using Popup Window&quot;)
          self.oUsePopupRadioBtn.toggled.connect(self.on_selected)
          self.oUsePopupRadioBtn.setChecked(True)
  
          self.settings = QSettings('LoneProgrammer2', 'qsettingsTest1')  # companyname, appname 
          self.settings.beginGroup(&quot;Promotion Dialog&quot;)
          self.oAutoPromoteRadioBtn.setChecked(
              bool(self.settings.value('auto-promote radio button checked state')))
          self.oUsePopupRadioBtn.setChecked(
              bool(self.settings.value('promote using popup radio button checked state')))
          self.settings.endGroup()
          print('AT APP OPENING:')
          print('self.oAutoPromoteRadioBtn.isChecked() = ', self.oAutoPromoteRadioBtn.isChecked())
          print('self.oUsePopupRadioBtn.isChecked() = ', self.oUsePopupRadioBtn.isChecked())
  
          oVertLayoutForRadioButtons = QVBoxLayout()
          oVertLayoutForRadioButtons.addWidget(self.oAutoPromoteRadioBtn)
          oVertLayoutForRadioButtons.addWidget(self.oUsePopupRadioBtn)
  
          self.groupbox = QGroupBox(&quot;Select pawn promotion method:&quot;)
          self.groupbox.setFixedWidth(300)
          self.groupbox.setFixedHeight(95)
          self.groupbox.setLayout(oVertLayoutForRadioButtons)
  
          self.oVertLayout = QVBoxLayout()
          self.oVertLayout.addWidget(self.groupbox)
          self.setLayout(self.oVertLayout)
  
      def on_selected(self):
          radio_button = self.sender()
  
          if radio_button.isChecked():
              if radio_button.text() == 'Automatically Promote to Queen':
                  print('set to auto-promote to queen')
              elif radio_button.text() == 'Promote Pawn Using Popup Window':
                  print('set to promote pawn to queen using popup window')
  
      def closeEvent(self, event):
          # save the vars from this session
          self.settings.beginGroup(&quot;Promotion Dialog&quot;)
          self.settings.setValue('auto-promote radio button checked state', self.oAutoPromoteRadioBtn.isChecked())
          self.settings.setValue('promote using popup radio button checked state', self.oUsePopupRadioBtn.isChecked())
          self.settings.endGroup()
  
          print()
          print('AT APP CLOSE:')
          print('self.oAutoPromoteRadioBtn.isChecked() = ', self.oAutoPromoteRadioBtn.isChecked())
          print('self.oUsePopupRadioBtn.isChecked() = ', self.oUsePopupRadioBtn.isChecked())
  
  
  if __name__ == &quot;__main__&quot;:
      app = QApplication(sys.argv)
  
      demo = MyApp()
      demo.show()
      sys.exit(app.exec_())
  </code></pre>