I'm trying to compile this code.
Header:
#ifndef SOCKETTEST_H
#define SOCKETTEST_H
#include <QObject>
#include <QSslSocket>
class SocketTest : public QObject
{
Q_OBJECT
public:
explicit SocketTest(QObject *parent = 0);
signals:
public slots:
void onError(QAbstractSocket::SocketError socketError);
};
#endif // SOCKETTEST_H
Source:
#include "sockettest.h"
SocketTest::SocketTest(QObject *parent) :
QObject(parent)
{
QSslSocket *socket = new QSslSocket(this);
connect(socket, &QSslSocket::error, this, &SocketTest::onError);
}
But I'm getting this error :
sockettest.cpp:7: error: no matching function for call to 'SocketTest::connect(QSslSocket*&, , SocketTest* const, void (SocketTest::*)(QAbstractSocket::SocketError))'
I want to use new syntax of connect() function:
QMetaObject::Connection QObject::connect(const QObject * sender, PointerToMemberFunction signal, const QObject * receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection) [static]
So, my question is: How to connect QSslSocket::error()
signal to SocketTest::onError()
slot using new syntax of connect function?