qt - Qtwebkit persistence Cookie is not working -
I am trying to implement a firmness in Qtwebkit based browsers to keep the section. I've expanded the QNetworkCookieJar I did not override a file, but just loaded one and loaded functions. The work is called explanation. I am getting the following error. Code Brusher code is taken in the example Qt5.1.
QVariant :: save: 'QList & lt; QNetworkCookie & gt; Unable to save type (type ID: 1038). Am I doing any wrong thing .. please help ... My implementation of QNetworkCookie is attached
Static Infected unsigned int JAR_VERSION = 23; #if 1 QT_BEGIN_NAMESPACE QDataStream and Operator & lt; & Lt; (QDataStream and Stream, const QList & lt; QNetworkCookie & gt; & amp; List) {Stream & lt; & Lt; JAR_VERSION; Stream & lt; & Lt; Quint32 (list.size ()); For (Int i = 0; I & lt; list. Size (); ++ i) Stream & lt; & Lt; List.at (i) .toRawForm (); Return stream; } QDataStream & amp; Operator & gt; & Gt; (QDataStream and Stream, QList & lt; QNetworkCookie & gt; & amp; List) {list.clear (); Quint 32 Edition; Stream & gt; & Gt; Edition; If (version! = JAR_VERSION) returns stream; Quint 32 count; Stream & gt; & Gt; Count; (Quint32 i = 0; i & lt; counts; ++ i) {QByteArray value; Stream & gt; & Gt; value; QList & LT; QNetworkCookie & gt; NewCookies = QNetworkCookie :: Pars Cookies (Price); If (new cookies.) () == 0 & amp; Amp; Value.length ()! = 0) {qWarning () & lt; & Lt; "Cookies: Unable to parse saved cookie:" & lt; & Lt; value; } For (int j = 0; j & lt; newcookies.count (); ++ j) list.append (newCookies.at (j)); If (stream. At ()) break; } Return stream; } QT_END_NAMESPACE #endifCookieer :: Cookware (QObject * Guardian): QNetworkCookieJar (guardian) {load (); } Cookies: ~ Cookies () {save (); } Zero Cookware :: Load () {QSettings Cookie Settings (". Cookies_dir / Browser / cookies.ini", QSettings :: IniFormat); Settle cookies (qvariant_cast & lt; QList & lt; QNetworkCookie & gt; & gt; (Cookie setting.value ("cookies"))); } Zero Cookware :: Save () {// purgeOldCookies (); Caststring Directory = "./cookies_dir/Browser"; If (! QFile :: exists) (Directory)) {QDir dir; Dir.mkpath (directory); } Quotes Cookie Settings (Directory + Qltin1 String ("/ cookies.ini"), QSettings :: IniFormat); QList & LT; QNetworkCookie & gt; Cookies = all cookies (); QWarning ("\ n \ n + ========================================== ============= + \ n \ n "); For (int i = cookies. Quote () - 1; i> = 0; -i) {qWarning () & lt; & Lt; Cookies.at (i) .domain (); QWarning () & lt; & Lt; Cookies.at (i) .name (); If (cookies.at (i) .isSessionCookie ()) cookies.removeAt (i); } QWarning ("\ n \ n + ========================================= ============== + \ n \ n "); CookieSettings.setValue (QLatin1String ("cookies"), QVariant :: fromValue & lt; QList & lt; QNetworkCookie & gt; & gt; (cookies)); } Zero cookery :: purgeOldCookies () {QList & lt; QNetworkCookie & gt; Cookies = all cookies (); If (cookies.isEmpty ()) return; Int oldCount = cookies.count (); QDateTime now = QDateTime :: currentDateTime (); For (int i = cookies.count () - 1; i> = 0; --i)! {If (cookies.at (i) .isSessionCookie () & amp; amp; cookies.at (i) .expirationDate () & lt; now;) cookies.removeAt (i); } If return (old password == cookies.count ()); SetAllCookies (cookies); } Bool CookieJar :: setCookiesFromUrl (constant QList & quot; QNetworkCookie & gt; & amp; cookieList; Constant QUrl & amp; URL) & quot; & Lt; Url; Return QNetworkCookieJar :: setCookiesFromUrl (cookieList, url); } I registered the cookware using Behole code. Jar = New cookie (this); WebView-> Page () - & gt; NetworkAccessManager () - & gt; SetCookieJar (jar); Text after "
You must call qRegisterMetaTypeStreamOperators & lt; QList & LT; QNetworkCookie & gt; & Gt; ("QList & lt; QNetworkCookie & gt;") before saving or loading in QSettings.
Comments
Post a Comment