Results 1 to 2 of 2

Thread: QWebPage -- How do I intercept image URLs before downloading?

  1. #1

    Default QWebPage -- How do I intercept image URLs before downloading?

    I am new to QT and new to C++. I am building a gui application that makes use of QWebView for the interface. I want to be able to intercept resource (images, javascript, css) urls prior to trying to access those resources so that I can change the URL.

    Why do I want to do this?

    I am using qrc files to manage images and urls, etc. This way they are included in the .exe. This means that resources need to be accessed using a url like this "/resource/index.html"

    To speed up development, I would rather access the non-compiled versions of the html and load the html from the filesystem. This works perfect, except one problem... Webkit does not know how to handle urls such as "/resource/index.html" It can handle "./resource/index.html" but then when I am not developing it will not load that as a qrc url.

    Does anyone have any ideas on how to do what I want to do?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebPage -- How do I intercept image URLs before downloading?

    Either take a look at the QWebPage::downloadRequested() signal or provide your own QNetworkAccessManager with reimplemented createRequest() method for WebKit. The latter is probably what you want, the former only lets you see the request but doesn't allow to modify it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Programmatically Save Image rendered in a QWebPage
    By last2kn0 in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2008, 06:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.