Commit dc20cf64 authored by Patrick José Pereira's avatar Patrick José Pereira

TCPLink: Add new errorOccurred for Qt 5.15 builds

Signed-off-by: 's avatarPatrick José Pereira <patrickelectric@gmail.com>
parent 1de3de31
...@@ -150,12 +150,21 @@ bool TCPLink::_hardwareConnect() ...@@ -150,12 +150,21 @@ bool TCPLink::_hardwareConnect()
Q_ASSERT(_socket == nullptr); Q_ASSERT(_socket == nullptr);
_socket = new QTcpSocket(); _socket = new QTcpSocket();
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QSignalSpy errorSpy(_socket, static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error)); QSignalSpy errorSpy(_socket, static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error));
#else
QSignalSpy errorSpy(_socket, &QAbstractSocket::errorOccurred);
#endif
_socket->connectToHost(_tcpConfig->address(), _tcpConfig->port()); _socket->connectToHost(_tcpConfig->address(), _tcpConfig->port());
QObject::connect(_socket, &QTcpSocket::readyRead, this, &TCPLink::readBytes); QObject::connect(_socket, &QTcpSocket::readyRead, this, &TCPLink::readBytes);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QObject::connect(_socket,static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error), QObject::connect(_socket,static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error),
this, &TCPLink::_socketError); this, &TCPLink::_socketError);
#else
QObject::connect(_socket, &QAbstractSocket::errorOccurred, this, &TCPLink::_socketError);
#endif
// Give the socket a second to connect to the other side otherwise error out // Give the socket a second to connect to the other side otherwise error out
if (!_socket->waitForConnected(1000)) if (!_socket->waitForConnected(1000))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment