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();
});

 

posted @ 2024-05-07 14:43  txwtech  阅读(59)  评论(0编辑  收藏  举报