我想使用此旧式connect调用的qt5样式:
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
SLOT(erreurSocket(QAbstractSocket::SocketError)));
我试过了
connect(socket, &QTcpSocket::error, this, &FenClient::erreurSocket);
没有成功:
FenClient.cpp
FenClient::FenClient()
{
setupUi(this);
socket = new QTcpSocket(this);
connect(socket, &QTcpSocket::error, this, &FenClient::erreurSocket);
FenClient.h
private slots:
void erreurSocket(QAbstractSocket::SocketError erreur);
最佳答案
根据docs:
因此,您的解决方案是:
connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &FenClient::erreurSocket);
关于c++ - 如何将此SIGNAL和SLOT转换为qt5 connect调用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55998495/