Jessica
Jessica

Reputation: 77

How convert QNetworkCookie to QString?

I am trying to convert QNetworkCookie to QString but I can't find a way how to do this. For example, I've tried to do something like this

QString cookie = QVariant(cookies_[i]).toString();

and this

QString cookie = (QString*)cookies_[i];

Nothing worked.

Upvotes: 1

Views: 282

Answers (1)

Jessica
Jessica

Reputation: 77

As @Aditya told, QNetworkCookie::value() works as QByteArray. So, problem solvetion for me is:

auto cookie = reply->manager()->cookieJar()->cookiesForUrl(webReportsUrl);//).value(0);
cookies = cookie[0].name() + "=" + cookie[0].value() + "; domain=" + cookie[0].domain() + "; path=" + cookie[0].path();
qDebug() << "Cookie: " << cookies;

But presented returns only cookies' value without a name, domain, and others.

Upvotes: 1

Related Questions