title: QSerialPort ->write() or read() not as expected on clicked() signal
body: <p>I'm working on a Qt5 project. I have a button that issues a clicked() signal and its slot has the following code which writes to the serial port:</p>
  <pre><code>void Dialog::on_startStream_clicked()
  {
      QByteArray ba;
      if(esp-&gt;isOpen()){
          esp-&gt;write(&quot;1&quot;);
          if(esp-&gt;canReadLine()){
              ba = esp-&gt;readLine();
              ba.replace(&quot;\xFE&quot;, &quot;&quot;);
              ba = ba.simplified();
              QString ba_with_time = stamp-&gt;currentDateTime().toString(&quot;MM.dd.yyyy hh:mm:ss  &quot;);
              ba_with_time.append(ba);
              ui-&gt;output-&gt;appendPlainText(ba_with_time);
              qDebug() &lt;&lt; ba_with_time;
          }
      }
  }
  </code></pre>
  <p>After establishing the connection to the serial port, the first time I click on the button nothing happens. Subsequent clicks work correctly.</p>
  <p>I'm using PlatformIO to upload the Arduino code to the ESP32 and in the PlatformIO serial monitor there is output immediately after I issue the command on the first time, which makes me think the problem is my Qt code.</p>
  <p>How can I fix it so that Qt can read the buffer on the first button click?</p>