Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML WebView load page from cache

QML WebView load page from cache

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m.kuncevicius
    wrote on last edited by
    #1

    Hello, it is possible to load page from cache using QML WebView? If there is an Internet connection I want to load page from Internet and if there is no - load page from cache.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      patrik08
      wrote on last edited by patrik08
      #2

      You can set..
      webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
      or open html file like epub file..
      setsource(Qurl("/user/home/ebook/xxx/chapter2/index.html"));
      Save local html page is also possibel..

      
      EpubView::EpubView(QWidget *parent) : QWebEngineView(parent) {
        modusNow = 1;
        this->setMinimumWidth(400);
        this->setMinimumHeight(400);
        this->setContentsMargins(0, 0, 0, 0);
        connect(QWebEngineView::page(), SIGNAL(loadFinished(bool)), this, SLOT(startHtmlGrab(bool)));
      }
      
      void EpubView::startHtmlGrab( bool ok) {
           if (ok) {
               QUrl uri = this->page()->url();
               if (uri.isLocalFile()) {
                  connect(this, SIGNAL(incomHtml(QString)), this, SLOT(handleHTML(QString)));
                  this->page()->toHtml([this](const QString& result) mutable { emit (void)incomHtml(result);});
               }
           }
      }
      
      

      from
      https://github.com/pehohlva/QOASIS/blob/master/test/dkernel/epubview.cpp

      Oh sorry i dont see QML.....
      QML -> https://doc.qt.io/qt-5/qml-qtwebengine-webengineprofile.html#httpCacheMaximumSize-prop

      1 Reply Last reply
      0
      • M Offline
        M Offline
        m.kuncevicius
        wrote on last edited by m.kuncevicius
        #3

        According (QtWebEngine 1.5) property cachePath path to cache by default is StandardPaths.writableLocation(StandardPaths.CacheLocation). Where are some files in that folder and none of them has extention .html (Some files has some JavaScript functions, others css and html tags inside). Is there any way to some how glue them to one page and display by using WebView component (QML)?
        0_1505219546685_Capture1.PNG

        @patrik08

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved