我正在尝试删除 cookie 但出现错误:
错误 C2440:“正在初始化”:无法从“const QNetworkCookie”转换为“QNetworkCookie &”
我很困惑为什么编译器提示 const QNetworkCookie
(我假设它提示我的 foreach()
)。
void PersistentCookieJar::deleteCookie(const QString cookieName) {
QList<QNetworkCookie> cookies = allCookies();
foreach(QNetworkCookie &cookie, allCookies()) {
if (cookie.name() == cookieName) {
cookie.setValue(""); // delete the cookie
break;
}
}
}
void PersistentCookieJar::deleteCookie(const QString cookieName) {
QList<QNetworkCookie> cookies = allCookies();
foreach(QNetworkCookie &cookie, cookies) {
if (cookie.name() == cookieName) {
cookie.setValue(""); // delete the cookie
break;
}
}
setAllCookies(cookies);
}
我是一名优秀的程序员,十分优秀!