title: Enabling QCheckBox when QCheckBox is checked
body: <p>I'm new to Qt and GUI programming and am unsure of the best way to connect a signal to to a slot when the parameter list doesn't match.  I have a settings dialog box made with Qt Designer and it contains a series of QCheckBoxes and QLineEdits, with the QLineEdits disabled by default.  I want to enable a QLineEdit when the QCheckBox next to it is checked.</p>
  
  <p>At first I thought to connect the QCheckBox::stateChanged signal to the QLineEdits::setEnabled slot, but when I looked I found they had different parameter types so this obviously won't work:</p>
  
  <pre><code>connect(checkBox1, SIGNAL(stateChanged(int)), lineEdit1, SLOT(setEnabled(bool)));
  connect(checkBox2, SIGNAL(stateChanged(int)), lineEdit2, SLOT(setEnabled(bool)));
  connect(checkBox3, SIGNAL(stateChanged(int)), lineEdit3, SLOT(setEnabled(bool)));
  </code></pre>
  
  <p>Next I thought to create setLineEditEnabled(int) function in the dialog box class to enable the appropriate QLineEdit when a QCheckBox is checked:</p>
  
  <pre><code>connect(checkBox1, SIGNAL(stateChanged(int)), settingsDialog, SLOT(setLineEditEnabled(int)));
  connect(checkBox2, SIGNAL(stateChanged(int)), settingsDialog, SLOT(setLineEditEnabled(int)));
  connect(checkBox3, SIGNAL(stateChanged(int)), settingsDialog, SLOT(setLineEditEnabled(int)));
  </code></pre>
  
  <p>When I came to write the setLineEditEnabled() function I realised there's no way to know which QCheckBox sent the signal, so I don't know which QLineEdit should be enabled:</p>
  
  <pre><code>void SettingsDialog::setLineEditEnabled(int checkState)
  {
      ????-&gt;setEnabled(checkState == Qt::Checked);
  }
  </code></pre>
  
  <p>The only solution I can think is to think of is to have a a series of functions in the dialog class, with one for each checkbox:</p>
  
  <pre><code>connect(checkBox1, SIGNAL(stateChanged(int)), settingsDialog, SLOT(setLineEdit1Enabled(int)));
  connect(checkBox2, SIGNAL(stateChanged(int)), settingsDialog, SLOT(setLineEdit2Enabled(int)));
  connect(checkBox3, SIGNAL(stateChanged(int)), settingsDialog, SLOT(setLineEdit3Enabled(int)));
  
  void SettingsDialog::setLineEdit1Enabled(int checkState)
  {
      lineEdit1-&gt;setEnabled(checkState == Qt::Checked);
  }
  
  void SettingsDialog::setLineEdit2Enabled(int checkState)
  {
      lineEdit2-&gt;setEnabled(checkState == Qt::Checked);
  }
  
  void SettingsDialog::setLineEdit3Enabled(int checkState)
  {
      lineEdit3-&gt;setEnabled(checkState == Qt::Checked);
  }
  </code></pre>
  
  <p>However, that seems a bit messy (there are actually seven QCheckBox-QLineEdit pairs so I'd need seven functions), and I feel I'm missing something that would make this easier.  If I knew which object sent the signal I could do it with a single function, which would be tidier.</p>
  
  <p>Is there a way get the object that sent the signal from the slot function?</p>
  
  <p>If there's no way to get the signalling object, is there a better solution to this that doesn't involve having multiple functions in the dialog class for enabling the QLineEdits?</p>
  
  <p>Thanks for your help.</p>