Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2090765
  • 博文数量: 229
  • 博客积分: 7217
  • 博客等级: 上校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-19 17:23
个人简介

个人主页https://xugaoxiang.com,微信公众号: Dev_Club 或者搜索 程序员Club

文章分类

全部博文(229)

文章存档

2017年(1)

2016年(20)

2015年(23)

2013年(1)

2012年(23)

2011年(68)

2010年(62)

2009年(31)

分类: LINUX

2011-01-30 14:08:57

QtWebKit provides support for features specified in HTML5 that improve the performance and capabilities of Web applications. These include client-side (offline) storage and the use of a Web application cache.

Client-side (offline) storage is an improvement over the use of cookies to store persistent data in Web applications.

QT默认是不支持这些的,需要自己添加相应的代码.以demos/browser为例,在browserapplication.cpp中的loadSettings函数中加入如下语句:

defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled,true);
defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled,true);
defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled,true);
defaultSettings->setOfflineStoragePath("/home/offline1");
defaultSettings->setOfflineWebApplicationCachePath("/home/offline2");
defaultSettings->setLocalStoragePath("/home/offline3");
defaultSettings->setOfflineStorageDefaultQuota(10*1024*1024);
defaultSettings->setOfflineWebApplicationCacheQuota(5*1024*1024);

或者

defaultSettings->setAttribute(QWebSettings::enablePersistentStorage(directory));

This method will simultaneously set and enable the (), (), () and ().

页面设置html5 cache请看http://dev.w3.org/html5/spec/Overview.html#appcache,再将页面放置在tomcat中

再用编译好的browser去访问该页面,接着关闭tomcat服务,在browser中刷新该页面,页面依旧可以显示。不过browser重启后再访问就失效了。在编译QT时应加上database的支持,如-qt-sql-sqlite。


阅读(5372) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~