Solved QtWebEngine cannot save cache
-
Hello,
When I used Qt6.2.0 with my windows program that uses QtWebEngine, the cache and cookies were not saved.I tried running
Qt/Examples/Qt-6.2.0/webenginewidgets/cookiebrowser
with Qt5.15.2 and Qt6.2.0, and it seems that cookies are saved with Qt5, but not with Qt6.
I addedQWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
, but it didn't work.
How can I enable cache saving in Qt6? -
Resolved.
https://doc-snapshots.qt.io/qt6-dev/qtwebengine-changes-qt6.htmlDefault Profile
The default profile is now off the record.
To have a standard browser profile with disk-cache and cookies, we recommend creating your own profile and using that explicitly.So, I used
m_webview->setPage(new QWebEnginePage(new QWebEngineProfile("MyProfile")));
instead ofQWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
, and it worked. -
Resolved.
https://doc-snapshots.qt.io/qt6-dev/qtwebengine-changes-qt6.htmlDefault Profile
The default profile is now off the record.
To have a standard browser profile with disk-cache and cookies, we recommend creating your own profile and using that explicitly.So, I used
m_webview->setPage(new QWebEnginePage(new QWebEngineProfile("MyProfile")));
instead ofQWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
, and it worked.