title: How to connect to QTcpSocket error signal in Qt
body: <p>I am trying to get the QTcpSocket error by using signal and slot. I did like this:</p>
  
  <pre><code>connect(clientConnection-&gt;tcpSocket, &amp;QTcpSocket::error, this, &amp;ClientInterface::displayError);
  
  void ClientInterface::displayError()
  {
      qDebug() &lt;&lt; clientConnection-&gt;tcpSocket-&gt;error();
      qDebug() &lt;&lt; clientConnection-&gt;tcpSocket-&gt;errorString();
  }
  </code></pre>
  
  <p>but I got this error:<br></p>
  
  <blockquote>
    <p>error: no matching function for call to 'ClientInterface::connect(QTcpSocket*&amp;, , ClientInterface*, void (ClientInterface::*)())'
         connect(clientConnection->tcpSocket, &amp;QTcpSocket::error, this, &amp;ClientInterface::displayError);</p>
  </blockquote>
  
  <p>I also tried to implement the slot with <code>QAbstractSocket::SocketError</code> parameter like this:<br> <code>void displayError(QAbstractSocket::SocketError);</code><br>
  But it showed the same error. </p>
  
  <p>Where did I do wrong?
  <br><br>
  <b>Edit:</b><br><br>
  I tried to connect like this as the answer says:</p>
  
  <pre><code>connect(clientConnection-&gt;tcpSocket, QOverload&lt;QAbstractSocket::SocketError&gt;::of(&amp;QAbstractSocket::error), this, &amp;ClientInterface::displayError);
  </code></pre>
  
  <p>But I got this problem:</p>
  
  <blockquote>
    <p>QObject::connect: Cannot queue arguments of type 'QAbstractSocket::SocketError'
    (Make sure 'QAbstractSocket::SocketError' is registered using qRegisterMetaType().)</p>
  </blockquote>