qt5.0转qt6.0SocketError 解决方法
问题描述:
//tcp_client.cpp:19:23: Static_cast from 'SocketError (QAbstractSocket::*)() const' to 'void (QTcpSocket::*)
//(QAbstractSocket::SocketError)' is not allowed
原因分析:
QtNetwork中的错误信号error换成了errorOccurred
QT5.0
connect(tcpClient,static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error),this,[=]{ qDebug()<<"tcp error:"+tcpClient->errorString(); });
QT6.0
connect(tcpClient,static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::errorOccurred),this,[=]{ qDebug()<<"tcp error:"+tcpClient->errorString(); });
欢迎讨论,相互学习。
cdtxw@foxmail.com