Qt6.2.3 QWebEngineView 咋就默认无痕浏览模式了?
最近项目从Qt5迁移到Qt6,有若干不兼容或者变动的地方,虽谈不上什么血泪史,但是一天内做了几十处的兼容性处理(好在项目不大),也是挺累人的。
本文重点说说QWebEngineView 咋就默认变成无痕处理模式了,如何咱们如何取消无痕模式,自定义设置缓存路径。
Profiles can be used to isolate pages from each other. A typical use case is a dedicated off-the-record profile for a private browsing mode. Using QWebEngineProfile() without defining a storage name constructs a new off-the-record profile that leaves no record on the local machine, and has no persistent data or cache. The isOffTheRecord() method can be used to check whether a profile is off-the-record.
先读懂这段话。QWebEngineProfile对象在构造的时候,如果不指定storage的名称,那么默认构造一个off-the-record 的profile对象,页面的cache和data将保存在缓存中,而不会在页面关闭时持久化到磁盘。
反过来说,只要我们对页面指定一个独一无二的profile,自然能在页面退出时将页面数据持久化。
*QWebEngineProfile::QWebEngineProfile(const QString &storageName, QObject parent = nullptr)
Constructs a new profile with the storage name storageName and parent parent.
The storage name must be unique.
A disk-based QWebEngineProfile should be destroyed on or before application exit, otherwise the cache and persistent data may not be fully flushed to disk.
See also storageName().
简单举个使用例子:
#include "widget.h"
#include <QWebEngineView>
#include <QApplication>
#include <QUrl>
#include <QDebug>
#include <QWebEngineProfile>
#include <QWebEngineSettings>
#include <QWebEnginePage>
#include <webview.h>int main(int argc, char *argv[])
{QApplication a(argc, argv);QWebEngineView* view = new QWebEngineView;QWebEngineProfile profile(a.applicationName()); // here's importantQWebEnginePage page(&profile);view->setPage(&page);QString _storageName = profile.storageName();QString cacheName = profile.cachePath();qDebug() << __FUNCTION__ << __LINE__ << _storageName << cacheName;QUrl url("https://www.iqiyi.com/v_1fzx7cxrde0.html?vfrm=pcw_home&vfrmblk=D&vfrmrst=712211_focus_A_image3");view->setUrl(url);view->load(url);view->show();return a.exec();
}
效果如上,无需每次都登录,可记住登录账号等信息~~
反过来,如果有朋友需要设置默认无痕模式,那么在Qt6的版本上使用,直接用默认的profile则行;Qt5上,与上使用类似
QWebEnginePage page(); // 不指定storage名称
就这样,简单记录下
附Qt6 在webEngine的变化点:
https://doc-snapshots.qt.io/qt6-dev/qtwebengine-changes-qt6.html
Qt6.2.3 QWebEngineView 咋就默认无痕浏览模式了?相关推荐
- php网页无痕预览,javascript,html5_如何应对用户使用无痕浏览模式,javascript,html5 - phpStudy...
如何应对用户使用无痕浏览模式 在开发过程中,由于一些页面会使用localStorage,sessionStorage ,在无痕浏览模式,本地存储不能用,会出现很多问题,看到过一种解决方案 functi ...
- 无痕浏览会被保密局的查到吗_无痕浏览模式真的安全吗?在操作中不留下“蛛丝马迹”?你怎么看...
2.不记录Cookies 3.不记录Internet临时文件 4.不记录网页表单数据(用户名.密码.搜索关键词等) 5.不记录历史访问记录 6.不记录撤销页面列表 无痕浏览模式能不能保护个人隐私呢? ...
- js判断无痕浏览模式(修改)
最近做web商城,遇到一个棘手的问题: 用户反映登录了商城之后,过一段时间就需要重新登录,频率很高,我们通过对该用户的访问记录进行检测,发现的确存在该问题.因为用户的信息是存在本地localStroa ...
- Storge 在 Safari 的无痕浏览模式中的坑
关于 Storge 在 Safari 的无痕浏览模式中的坑 前言 今天遇到了一个诡异的bug,一个网页在微信浏览器中是可以正常显示的,而在一些用户的 Safari 中却无法正常渲染.真是日了狗了!检查 ...
- chrome无痕浏览模式中使用插件
前言 默认情况下,在使用google浏览器的时候,是无法使用插件的,如图本该是插件位置却没有 操作 那么该如何进行操作呢 打开右上角设置中的扩展程序,并点击 这个时候你会回到正常浏览模式,接下来找到你 ...
- ios中safari无痕浏览模式下,localStorage的支持情况
前言 前阶段,测试提了个bug,在苹果手机中无痕模式下,搜索按钮不好使,无法跳页,同时搜索历史也没有展示(用户搜索历史时使用localStorage存储). 正文 iOS上Sarfari在无痕模式下, ...
- Live Server插件默认打开浏览器的无痕浏览模式解决方法
很多人在VS code中装了Live Server这个插件,启动后是默认的无痕模式.这个模式下Chrome会把插件禁用.导致很多调试开发工具无法使用.比如VueDevtools. 解决方法(不听废话直 ...
- Chrome 插件:无痕浏览模式下加载插件、启用插件设置方法
通过 chrome://extensions/ 进入 chrome 插件列表,进入插件的详细信息页. 在无痕模式下启用的开关勾选上. 然后就好了. 喜欢的点个赞❤吧!
- playwright 关闭无痕浏览模式
使用 launchPersistentContext 即可,需提供一个文件夹存放 cookie 等数据 // @ts-check const { chromium } = require(" ...
最新文章
- zoj 3627(贪心)
- Leetcode 209. 长度最小的子数组 解题思路及C++实现
- 明日科技的python书籍怎么样_零基础学习Python不可错过的5本书籍
- ssh登录远程服务器_设置iTerm2免密登陆ssh远程服务器
- repeater导出excel html,Repeater显示数据,并且导出到excel
- cadence设计运算放大器_21.比较器的原理与特性,它与运算放大器的本质区别总结归纳...
- 2.9 穆尔彭罗斯伪逆
- android冒烟测试自动化,安卓自动化测试总结(五)——测试结果发送及内容展示...
- Jquery与.net MVC结合,通过Ajax
- Qt之多线程编程初识
- 过水滑环的结构和工作原理
- 方差np.var()
- 软路由硬件, 研究了一圈还是J1900 , i211网卡又如何
- 电脑可以上QQ但是打不开网页
- 通过ESP8266手机或电脑浏览器网页能控制远程任意组任意路继电器开关并收发单片机指令 测试OK
- 大学生毕业后的档案问题如何处理
- 图解GPS原理 为什么需要4颗卫星才能定位,而不是3颗
- C++对象的底层原理都在这儿了,还敢说学不会?
- python3群控手机_带你用 Python 实现自动化群控设备
- 多线程基础(四)之死锁