[Interest] Odd new-style connect()/disconnect() error with Qt 5.5.0
Bob Hood
bhood2 at comcast.net
Wed Oct 14 19:50:10 CEST 2015
I'm having an odd compiler error using the new-style connect() and
disconnect() with a QTcpSocket object. I'm working under Linux with Qt 5.5.0
and QtCreator. I built Qt 5.5.0 myself without modifications, and then built
QtCreator against it.
Given a QSharedPointer<QTcpSocket> called 'stream', the connect() code looks like:
connect(stream.data(), &QTcpSocket::readyRead, this,
&TCPChannel::slot_data_available);
connect(stream.data(), &QTcpSocket::disconnected, this,
&TCPChannel::slot_client_lost);
connect(stream.data(), &QTcpSocket::stateChanged, this,
&TCPChannel::slot_state_changed);
connect(stream.data(), &QTcpSocket::error, this,
&TCPChannel::slot_socket_error);
The error occurs on the last line with QTcpSocket::error (none of the other
lines create errors. My disconnect code looks like:
disconnect(stream.data(), &QTcpSocket::readyRead, this,
&TCPChannel::slot_data_available);
disconnect(stream.data(), &QTcpSocket::disconnected, this,
&TCPChannel::slot_client_lost);
disconnect(stream.data(), &QTcpSocket::stateChanged, this,
&TCPChannel::slot_state_changed);
disconnect(stream.data(), &QTcpSocket::error, this,
&TCPChannel::slot_socket_error);
where a similar error occurs on the last line with QTcpSocket::error.
The error for the connect() call states:
../../../Common/Source/Channel.cpp: In member function 'virtual void
SPlay::TCPChannel::connect_channel()':
../../../Common/Source/Channel.cpp:104:90: error: no matching function for
call to 'SPlay::TCPChannel::connect(QTcpSocket*, <unresolved overloaded
function type>, SPlay::TCPChannel* const, void
(SPlay::TCPChannel::*)(QAbstractSocket::SocketError))'
result = connect(stream.data(), &QTcpSocket::error, this,
&TCPChannel::slot_socket_error);
^
and then later in the output:
/usr/local/qt/5.5.0/64_dll/include/QtCore/qobject.h:254:13: note:
template argument deduction/substitution failed:
../../../Common/Source/Channel.cpp:104:90: note: couldn't deduce
template parameter 'Func1'
result = connect(stream.data(), &QTcpSocket::error, this,
&TCPChannel::slot_socket_error);
^
^
and disconnect():
../../../Common/Source/Channel.cpp: In member function 'virtual void
SPlay::TCPChannel::disconnect_channel()':
../../../Common/Source/Channel.cpp:115:85: error: no matching function for
call to 'SPlay::TCPChannel::disconnect(QTcpSocket*, <unresolved overloaded
function type>, SPlay::TCPChannel* const, void
(SPlay::TCPChannel::*)(QAbstractSocket::SocketError))'
disconnect(stream.data(), &QTcpSocket::error, this,
&TCPChannel::slot_socket_error);
^
"SPlay" is a namespace, and my slots (within that namespace) look like:
protected slots:
virtual void slot_data_available();
virtual void slot_client_lost();
void slot_state_changed(QAbstractSocket::SocketState state);
void slot_socket_error(QAbstractSocket::SocketError error);
I also tried substituting "QAbstractSocket" for "QTcpSocket" in the code, and
that had no effect--same errors with different names.
Any insights as to why only that single signal is giving me grief? I'm sure
it's something obvious that I'm overlooking. This same code using the
old-style connect works fine under Windows using Qt 5.5.0.
More information about the Interest
mailing list