I'm trying to collect QNetworkCookies in a QSet. I create the QSet QSet<QNetworkCookie> cookies
and then insert the cookies with
cookies.insert(cookie);
The compiler then tells me, that there is no qHash for QNetworkCookie, so I added an inline method like you can see in the code listing below. The compiler now is happy, but the method never gets called and the set contains the same cookie multiple times. Can someone point me in the right direction?
#ifndef BROWSER_H
#define BROWSER_H
#include <QDebug>
#include <QMainWindow>
#include <QNetworkCookie>
#include <QObject>
#include <QWebEngineView>
class Browser : public QMainWindow
{
Q_OBJECT
private:
QWebEngineView *webEngine;
QSet<QNetworkCookie> cookies;
public:
explicit Browser(const QUrl &url);
protected slots:
void finishLoading(bool);
void handleCookieAdded(const QNetworkCookie &cookie);
};
inline uint qHash(const QNetworkCookie &key, uint seed)
{
uint hash = qHash(key.domain(), seed) ^ qHash(key.name(), seed);
qDebug() << "qHash " << key.domain() << " " << key.name() << " " << hash;
return hash;
}
#endif // BROWSER_H