Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPixmap sometimes does not load file, other times it does

QPixmap sometimes does not load file, other times it does

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 648 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qtdummy
    wrote on last edited by
    #1

    This is a similar application as the windows photo viewer: I have a directory with 145 files.The user picks a file and the program displays it on the screen. Then the user presses a left/right button to display the previous/next file. Internally I keep all the pixmaps in memory (for speed reasons) and only load when a new file is selected. Some files return NULL (not loaded) when using "new QPixmap(filename);" But only if I start from file 1 and work up to it. If I start with the file it displays fine. It looks like a 'not enough memory' problem as from there it only shows/load small pictures, anything as long as the total memory<404M. I checked and I have used ~397M. I would assume I have ~1.6G still available (windows-7 x64 machine with 16G memory)

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It's hard to say anything without looking at the code.

      bq. I keep all the pixmaps in memory (for speed reasons) and only load when a new file is selected

      I don't think I follow. So do you load all at once or not? Or do you load on demand and just never delete? In any case, this seems terrible wasteful. I mean 400MB for a picture viewer? What if there are 1000 files? You'll run out of address space pretty quick if it's a 32 bit app.
      It's not a direct response to your problem, as, as I said, it's hard to guess what's happening, but I would consider changing your design to keep around say 5 or 7 of the images - the current one, two/three previous and pre-load ahead the next two/three. When you switch (left or right) you could delete from one side and load on the other. If you do it in a separate thread the performance and smoothness would be much better.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved