Results 1 to 5 of 5

Thread: Too Much RAM used by QGraphicsScene

  1. #1
    Join Date
    May 2010
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Too Much RAM used by QGraphicsScene

    Hey All,

    I'm trying to create a mosaic of several big .png images
    The images are arranged in a long ribbon, and I garuntee that no more than 5 are visible at a time.
    I need to use a lot of the functionality of a QGraphicsScene, and QGraphicsView (zooming, adding annotation, drawing), so doing this in a QWidgit would be quite difficult.

    The problem I have is RAM usage. When all the images load, I consume more memory than is allowable.

    What I want to do is build functionality into my already existing Sub-class of QGraphicsItem, allowing images to be cleared from RAM when they are sufficiently out of the viewing window, and have them loaded again when they are needed.

    -I cannot find any simple way to tell where the viewing window is when I am using ScrollHandDrag drag mode.
    -I cannot find any simple way to clear images from RAM temporarily.

    -I can maintain the location and size of my QGraphicsItem without depending on QPixmap geometry

    Can anyone give me any hints what I can do to accomplish these goals?

  2. #2
    Join Date
    May 2010
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Too Much RAM used by QGraphicsScene

    Ok, I've figured out how to delete the major components from my sub-classed QGraphicsItems. Now I just need a way to tell when they are no longer in the viewport of my QGraphicsView. I have looked all over for a signal that is emitted when the viewport moves, and it seems that there is not one.

    Any help would be appreciated.

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Too Much RAM used by QGraphicsScene

    You'll probably have to intercept one of the event handlers; there are a number in QAbstractScrollArea that sound like they might be useful.

  4. #4
    Join Date
    May 2010
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Too Much RAM used by QGraphicsScene

    That was what I needed,

    Solution:
    override QAbstractScrollArea:aintEvent

    Thanks

  5. #5
    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: Too Much RAM used by QGraphicsScene

    I would do it differently. I would have a QPixmapCache that was able to hold some amount of images. Then I would have my own class for representing items. Painting routine of the item class would grab the contents of the image from the cache instead of its own member variable. The cache would be responsible for getting rid of least recently used items. If a required item was missing in the cache, it could then be loaded back from disk. This way everything would work on its own without the need of deleting and creating items all the time.
    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. Bug in QGraphicsScene?
    By tbcpp in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2009, 15:23
  2. QGraphicsScene update?
    By Gurdt in forum Qt Programming
    Replies: 11
    Last Post: 17th April 2009, 10:03
  3. in QGraphicsScene matrix of other QGraphicsScene
    By Noxxik in forum Qt Programming
    Replies: 5
    Last Post: 15th February 2009, 18:27
  4. QGraphicsSCene
    By bhogasena in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2009, 00:58
  5. Help on QGraphicsScene
    By Sandip in forum Qt Programming
    Replies: 1
    Last Post: 11th April 2008, 15:20

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.