因为我把应用程序的Qt5改成了Qt6,
什么对Qt5有效(为了保存cookies,我跟踪了这个线程QT 5.6 QWebEngine doesn't save cookies),
现在不管用了:
QWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
QWebEngineProfile* defaultProfile = QWebEngineProfile::defaultProfile();
defaultProfile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
defaultProfile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
QHttpPart* header = new QHttpPart;
header->setRawHeader("X-Frame-Options", "ALLOWALL");
defaultProfile->setCachePath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
defaultProfile->setPersistentStoragePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));我要救饼干。
发布于 2022-03-31 14:45:28
解决办法是:
QWebEngineProfile *profile = new QWebEngineProfile(QString::fromLatin1("MyApplication.%1").arg(qWebEngineChromiumVersion())); // unique profile store per qtwbengine version
QWebEnginePage *page = new QWebEnginePage(profile); // page using profile
QWebEngineView *view = new QWebEngineView();
view->setPage(page);
view->setUrl(AccueilUrl);
view->setZoomFactor(1.2);
setCentralWidget(view);https://stackoverflow.com/questions/71639265
复制相似问题