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。
阅读(5433) | 评论(0) | 转发(0) |