如何让Qt支持HTML 5数据库?

Mic*_*ine 4 c++ html5 qt webkit qtwebkit

我正在使用Qt 4.7.1并在我的应用程序中嵌入了一个webview.但是在尝试访问http://webkit.org/demos/sticky-notes/以测试HTML 5数据库功能时出现以下错误

Failed to open the database on disk.  This is probably because the version 
was bad or there is not enough space left in this domain's quota
Run Code Online (Sandbox Code Playgroud)

我使用以下命令编译了我的静态Qt库:

configure --prefix=/usr/local/qt-static-release-db --accessibility --multimedia 
--audio-backend --svg --webkit --javascript-jit --script --scripttools 
--declarative --release -nomake examples -nomake demos --static --openssl -I
/usr/local/ssl/include -L /usr/local/ssl/lib -confirm-license -sql-qsqlite 
-sql-qmysql -sql-qodbc
Run Code Online (Sandbox Code Playgroud)

Ari*_*yat 5

检查QWebSettings文档.

特别是,您必须使用setAttribute启用QWebSettings :: OfflineStorageDatabaseEnabled 使用setOfflineStoragePath指出本地存储位置(例如QDesktopServices :: DataLocation).

您可能希望每页执行此操作,但作为示例,可以使用以下命令完成全局操作:

    QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
    QWebSettings::globalSettings()->setOfflineStoragePath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
Run Code Online (Sandbox Code Playgroud)