Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can we restrict QWebView not to download some js and css files.

How can we restrict QWebView not to download some js and css files.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 970 Views
  • 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.
  • CKurduC Offline
    CKurduC Offline
    CKurdu
    wrote on last edited by
    #1

    Hi
    After QWebView::load() method I want to monitor loading files(js,css..) and cancel some of them. But I didn't find any event handler or event type. How can we do it?

    You reap what you sow it

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by p3c0
      #2

      Hi,

      You can do it in following way:

      • Create custom QNetworkAccessManager class by subclassing it.
      • Re-implement createRequest in it. It will be called everytime a new request is done by QWebview.
        Something like this:
      QNetworkReply *MyQNAM::createRequest ( Operation op, const QNetworkRequest & req, QIODevice * outgoingData){
              QNetworkReply *reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
              qDebug() << req.url();
              return reply;
      }
      
      • Get the current URL from QNetworkRequest req. You can filter according to it.
      • Finally set this custom QNetworkAccessManager to QWebView's page() using setNetworkAccessManager.

      Hope this helps...

      157

      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