首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QtWebEngine,如何在C++/Qt6.2.4中保存饼干?

QtWebEngine,如何在C++/Qt6.2.4中保存饼干?
EN

Stack Overflow用户
提问于 2022-03-27 18:40:11
回答 1查看 247关注 0票数 0

因为我把应用程序的Qt5改成了Qt6,

什么对Qt5有效(为了保存cookies,我跟踪了这个线程QT 5.6 QWebEngine doesn't save cookies),

现在不管用了:

代码语言:javascript
复制
    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));

我要救饼干。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-31 14:45:28

解决办法是:

代码语言:javascript
复制
    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);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71639265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档