QObjectconnect&m_socket &QTcpSocketerrorOccurred QAbstractSocketSocketError error 获取错误代码 QAbstractSocketSocketError errorCode = m_socketerror; 根据错误代码进行相应处理 switch errorCo
The error occurs because the errorOccurred signal does not exist in the QTcpSocket class. The correct signal to use is error.
To fix the error, change the QObject::connect line to:
QObject::connect(&m_socket, QOverload<QAbstractSocket::SocketError>::of(&QTcpSocket::error), [](QAbstractSocket::SocketError error){
Additionally, the lambda function captures this implicitly, which is not allowed in a lambda function inside a member function. To fix this, you can explicitly capture &m_socket instead of this.
The corrected code would be:
QObject::connect(&m_socket, QOverload<QAbstractSocket::SocketError>::of(&QTcpSocket::error), [&m_socket](QAbstractSocket::SocketError error){
This should resolve the compilation errors
原文地址: https://www.cveoy.top/t/topic/iBfO 著作权归作者所有。请勿转载和采集!