title: Qt5: serial port signal-slots mechanism signal connect to the wrong slot
body: <p>I was confused about qt signal-slot.  I used the following connect, but it connect to another slot.</p>
  
  <pre><code> void MainWindow::on_otpburndata1Btn_Rd_clicked()
  {
      if(serialPort-&gt;clear(serialPort-&gt;AllDirections)){
          QByteArray otpburndata1ord;
          otpburndata1ord.resize(3);
          otpburndata1ord[2]=0x02;
          otpburndata1ord[1]=0x08;
          otpburndata1ord[0]=0x1D;
          serialPort-&gt;write(otpburndata1ord.data(),3);
          connect(serialPort,SIGNAL(readyRead()),this,SLOT(receiveOtpBurnData1()));
      }
  }
  
  void MainWindow::receiveOtpBurnData1(){
      QByteArray otpburndata1;
      otpburndata1.resize(1);
      if(serialPort-&gt;bytesAvailable()==1){
      otpburndata1 = serialPort-&gt;readAll();
      if(otpburndata1[0]&amp;0x01){
          ui-&gt;OTP_DATA0-&gt;setStyleSheet("background-color:red");
          ui-&gt;OTP_DATA0-&gt;setText("1");
          flagThree[0]=1;
      }else{
          ui-&gt;OTP_DATA0-&gt;setStyleSheet("background-color:rgb(170, 255, 127)");
          ui-&gt;OTP_DATA0-&gt;setText("0");
          flagThree[0]=0;
      }
      ...
      ...
      ...
    }
  }
  </code></pre>
  
  <p>As I used another function before this on_otpburndata1Btn_Rd_clicked() function. When I clicked the Button:otpburndata1Btn_Rd, it read the data from the port,but connect to another slot  otprddata1Received(), not the right slot receiveOtpBurnData1(). The prior code is as following:</p>
  
  <pre><code>     void MainWindow::on_otprddata1Btn_clicked()
  {
      if(serialPort-&gt;clear(serialPort-&gt;AllDirections)){
          QByteArray otprdata1ord;
          otprdata1ord.resize(3);
          otprdata1ord[0]=0x9D;
          otprdata1ord[1]=0x00;
          otprdata1ord[2]=0x02;
          serialPort-&gt;write(otprdata1ord.data(),3);
          connect(serialPort,SIGNAL(readyRead()),this,SLOT(otprddata1Received()));
      }
  }
  
  void MainWindow::otprddata1Received(){
      QByteArray  otprdata1;
      otprdata1.resize(1);
      if(serialPort-&gt;bytesAvailable()==1){
          otprdata1 = serialPort-&gt;readAll();
          if(otprdata1[0]&amp;0x01){
              ui-&gt;OTP_RD_DATA0-&gt;setStyleSheet("background-color:red");
              ui-&gt;OTP_RD_DATA0-&gt;setText("1");
          }else{
              ui-&gt;OTP_RD_DATA0-&gt;setStyleSheet("background-color:rgb(170, 255, 127)");
              ui-&gt;OTP_RD_DATA0-&gt;setText("0");
          }
          ....
  }
  </code></pre>