Qt 错误解决:QObject::connect 中的 QTcpSocket::errorOccurred 信号不存在
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/qh6u 著作权归作者所有。请勿转载和采集!