Solved no matching function for call to 'of'
-
I'm trying to run the official QT chat example from GitHub
but while opening the client in constructor I see an error no matching function for call to 'of'ChatClient::ChatClient(QObject *parent) : QObject(parent) , m_clientSocket(new QTcpSocket(this)) , m_loggedIn(false) { ... // Forward the error signal, QOverload is necessary as error() is overloaded, see the Qt docs connect(m_clientSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ChatClient::error); ... }
I simply fixed this by replacing
QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error)
with
&QAbstractSocket::error
on build I see
The same error no matching function for call to 'of' is on the server side too
ServerWorker::ServerWorker(QObject *parent) : QObject(parent) , m_serverSocket(new QTcpSocket(this)) { .... connect(m_serverSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ServerWorker::error); }
and after the same fix I see a warning QAbstractSocket::error is not a signal [clazy-connect-non-signal]
How to make this project work?
-
@63350541 said in no matching function for call to 'of':
SocketError
you're probably using Qt 5.15 ?
than use:
connect(m_clientSocket, &QAbstractSocket:: errorOccurred, this, &ChatClient::error); -
@63350541 said in no matching function for call to 'of':
SocketError
you're probably using Qt 5.15 ?
than use:
connect(m_clientSocket, &QAbstractSocket:: errorOccurred, this, &ChatClient::error); -
@63350541 said in no matching function for call to 'of':
run the official QT chat example
This doesn't look like an offcial Qt example.
Official chat examples can be found here
- https://doc.qt.io/qt-5/qtnetwork-network-chat-example.html
or here - https://doc.qt.io/qt-5/qtwebsockets-simplechat-example.html
on build I see
The same error no matching function for call to 'of' is on the server side too
The message already tells you what went wrong.
Look at QAbstractSocket::error if you are using a Qt Version < 5.15 or simply follow what @J-Hilk suggested if you have 5.15 - https://doc.qt.io/qt-5/qtnetwork-network-chat-example.html