[Interest] Not possible to connect QTcpSocket::error signal the "Qt5-way"?

Ola Røer Thorsen ola at silentwings.no
Fri Nov 22 16:56:47 CET 2013


Hi all,

I've started using the new "Qt5" way of connecting signals and slots, to
get errors compile-time instead of runtime. Great stuff.

Here is one I struggle to connect. If you have a QTcpSocket, and want to
handle the error signal in a slot called tcpSocketError, a connect like
this:

connect(tcp_socket_, &QTcpSocket::error, this, &MyClass::tcpSocketError);


fails, the compiler says

error: no matching function for call to 'MyClass::connect(QTcpSocket*&,
<unresolved overloaded function type>, MyClass* const, void
(MyClass::*)(QAbstractSocket::SocketError))'

All the other signals in QTcpSocket connect fine using the same syntax. So
for now I use the "old" connect for the error signal, and that works fine.

connect(tcp_socket_, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(tcpSocketError(QAbstractSocket::SocketError)));


Is this a bug in Qt, or did I not use the correct syntax? I recon this has
to do with QAbstractSocket having the error() function as well as an error
signal.

Cheers,
Ola
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131122/fad72afd/attachment.html>


More information about the Interest mailing list