Results 1 to 4 of 4

Thread: QNetworkAccessManager and QNetworkDiskCache ownership

  1. #1
    Join Date
    May 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QNetworkAccessManager and QNetworkDiskCache ownership

    Hi everyone,

    I'm creating an application that uses several QNetworkAccessManagers instances. I would like to share the same files from the default cache directory between these QNetworkAcessManagers, but, Qt documentation says that: "Currently you can not share the same cache files with more then one disk cache.".

    So, my idea is to share a single instance of QNetworkDiskCache between all QNetworkAccessManager instances, but, it was not possible because QNetworkAccessManager takes the ownership of QNetworkDiskCache.

    My questions are:

    1) Is there any way to disable the ownership ?
    2) If not, anyone has suggestions in how to solve my problem?

    Thanks in advance!

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QNetworkAccessManager and QNetworkDiskCache ownership

    I'd have to ask why you'd want more than one QNetworkAccessManager. It's not really processor intensive, so would not benefit from being multi-threaded, and you can make lots of requests at once.

    Alternatively, you could subclass QAbstractNetworkCache and set the cache to that.
    Last edited by squidge; 14th May 2010 at 22:58.

  3. The following user says thank you to squidge for this useful post:

    zacao (15th May 2010)

  4. #3
    Join Date
    May 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager and QNetworkDiskCache ownership

    I'm not sure if what I'm doing is a good practice, but, in fact, I have a couple of instances of QWebPage each one with a QNetworkAccessManager respectivelly. Each QWebPage is accessing differents servers at the same time. Is there another way for doing this? For example, can I use the same QNetworkAccessManager for all QWebPage instances?

    Thanks again!

  5. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QNetworkAccessManager and QNetworkDiskCache ownership

    I would assume so, considering the asynchronous nature of it.

Similar Threads

  1. QNetworkAccessManager within QThread
    By Tomdarkness in forum Newbie
    Replies: 17
    Last Post: 26th August 2014, 15:12
  2. using QWebView cache with QNetworkDiskCache
    By Jann3 in forum Qt Programming
    Replies: 3
    Last Post: 7th October 2009, 13:23
  3. Thread Ownership Problem
    By tntcoda in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2009, 00:18
  4. Replies: 1
    Last Post: 9th February 2008, 12:46
  5. Replies: 2
    Last Post: 31st May 2006, 21:52

Tags for this Thread

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.