1
votes

I've this code snippet:

class Server{
public slot:
    static void readMessage();
};

// somewhere in the main code...
connect(tcpsocket, &QTcpSocket::readyRead, Server::readMessage);

error: no matching function for call to 'QObject::connect(const Object*&, void (QIODevice::&)(), const Object&, void (Server::*&)(), Qt::ConnectionType)' return connect(sender, signal, sender, slot, Qt::DirectConnection);

I don't know how to deal with that.

1
Maybe this could help : stackoverflow.com/a/9428213/6165833ymoreau
You can do this in Qt5 only. Which version of Qt do you use?vahancho
I use Qt_5_9_1cg f
Why you need "static" modifier here?stanislav888
This syntax works: QObject::connect(tcpsocket, &QTcpSocket::readyRead, &Server::readMessage);Mohammad Kanan

1 Answers

0
votes

Try this:

connect( tcpsocket, &QTcpSocket::readyRead, [](){ Server::readMessage(); });

Note: This will need C++11 compiler features.