Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3633418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:39:02+00:00 2026-05-19T00:39:02+00:00

How to tell QWebPage not to load specific type of resources like js, css

  • 0

How to tell QWebPage not to load specific type of resources like js, css or png?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:39:02+00:00Added an answer on May 19, 2026 at 12:39 am

    The solution is to extend QNetworkAccessManager class and override it’s virtual method QNetworkAccessManager::createRequest In our implementation we check the path of the requested url and if it’s the one we don’t want to download we create and hand over an empty request instead of the real one.
    Below is a complete, working example.

    #include <QApplication>
    #include <QUrl>
    
    #include <QtWebKit/QWebPage>
    #include <QtWebKit/QWebFrame>
    
    #include <QtNetwork/QNetworkAccessManager>
    #include <QtNetwork/QNetworkRequest>
    #include <QtNetwork/QNetworkReply>
    #include <QDebug>
    
    
    class NAM : public QNetworkAccessManager {
    
        Q_OBJECT
    
    protected:
    
        virtual QNetworkReply * createRequest(Operation op,
                                              const QNetworkRequest & req,
                                              QIODevice * outgoingData = 0) {
    
            if (req.url().path().endsWith("css")) {
                qDebug() << "skipping " << req.url();
                return QNetworkAccessManager::createRequest(QNetworkAccessManager::GetOperation,
                                                            QNetworkRequest(QUrl()));
            } else {
                return QNetworkAccessManager::createRequest(op, req, outgoingData);
            }
        }
    };
    
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QWebPage page;
        NAM nam;
    
        page.setNetworkAccessManager(&nam);
        page.mainFrame()->load(QUrl("http://google.com"));
    
        app.exec();
    }
    
    #include "main.moc"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please tell, how can i determine, the browser supports canvas (paperjs), or not ?
Please tell me if I got this wrong. Anchor point is like a movable
Please tell me why i am getting ClassCastException in this case I have type
Please tell me how to store the level information (like angry birds levels display
plz tell me whats wrong in code bcz i m not able to add
Tell me, how can I serialize/deserialize the fusion::vector object type? Thanks.
Please tell me, Is Jetty non-blocking web server by default or not? For example,
Tell me please, how to use getBulkUserInformationFor: method correctly? I have Could not authenticate
tell me please, how can i add top panel like on a screenshot? (with
tell some big, diff between order by and group by, like sort columns data=>order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.