Results 1 to 3 of 3

Thread: Saving webkit page image resources from memory

  1. #1
    Join Date
    Jul 2010
    Posts
    6
    Platforms
    MacOS X Unix/X11 Windows

    Default Saving webkit page image resources from memory

    Hi all,

    I have a quick question and would appreciate it someone could tell me if im completely off the track.

    What I'm trying to do save to disc all loaded images in memory that come from a page that is loaded by webkit.
    What I have done is intercept each QUrl by subclassing the QNetworkAccessManager which gives me the URL of the file its is referencing on override method "createRequest". This is fine however I am interested in the URL and image data when the request is finished (when createRequest is called the data parameter is empty although I do get the URL and other bit of information). I would like to intercept the loaded image data and save each to the harddrive. How would I intercept the loaded image data?

    Am I heading in the right direction with this or there another better way to do this?

    Thanks in advance

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

    Default Re: Saving webkit page image resources from memory

    I think it might be easier to attach a custom network cache to WebKit's QNetworkAccessManager so that everything WebKit downloads goes to your custom code where you can do with it whatever you want.
    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.


  3. #3
    Join Date
    Jul 2010
    Posts
    6
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Saving webkit page image resources from memory

    thank you - you are a legend!

    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
    diskCache->setCacheDirectory("cacheDir");
    manager->setCache(diskCache);

    That gives me a local folder with the cached files. From there I added a finished signal to the QNetworkAccessManager and dug into the cached files : manager->cache()->data(QUrl)->readAll()
    and hey presto!

    I had one main problem with my previous attempt - I was not able to get a bytearray for images back from the QNetworkAccessManager finished callback for some reason? I could intercept text though. strange.

    Thank you so much

Similar Threads

  1. webkit- Memory consumption increases per page load ?
    By Thành Viên Mới in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2011, 10:55
  2. Loading and saving in-memory SQLITE databases
    By miraks in forum Qt Programming
    Replies: 10
    Last Post: 27th April 2010, 22:24
  3. Replies: 0
    Last Post: 15th March 2010, 09:11
  4. Do resources in QRC files consume memory?
    By TheNewGuy in forum Newbie
    Replies: 1
    Last Post: 7th December 2009, 09:07
  5. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 15:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.