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. Qt load large number image and display it efficiently.
QtWS25 Last Chance

Qt load large number image and display it efficiently.

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.6k 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.
  • H Offline
    H Offline
    haris123
    wrote on last edited by
    #1

    I need to display large number of images in a Window like in a grid, and the image count can be more that 10000. Currently I have created a tableView and displaying image in each cell. But this creating problem when the image number is very large and the application uses considerable amount of RAM.

    I found in QML ImageView there is an option for cache and the image is loading when only scroll to that area. But my project is widget based. So is there anything exist on Qt widget based applications. Like load and display images only when we scroll to that area.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What are you using to do the displaying of the image ?

      In any case, you might be interested by QPixmapCache

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        asanka424
        wrote on last edited by
        #3

        Are you using full resolution or just thumbnails?

        1 Reply Last reply
        0
        • H Offline
          H Offline
          haris123
          wrote on last edited by
          #4

          I need to display, 128x128 pixel size, in a table grid.

          This is the relevant part of the code,

          int totalColumn = 15;
          int cellWidth = 128;
          int cellHeight = 128;
          for(int i=0;i<ImagePathList.size();i++){
                  QString imagePath =  imageDir+"/"+ImagePathList.at(i);
                  QPixmap pix(imagePath);
                  if(!pix.isNull()){
                    pix= pix.scaled(cellWidth,cellHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                    QStandardItem *item = new QStandardItem();
                    item->setData(QVariant(pix), Qt::DecorationRole);
                    model->setItem(row, col, item);
          
                    col++;
                    if(col==totalColumn){
                        col=0;
                        row++;
                    }
          
                  }
              }
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You should write you own model and pixmap cache.

            Doing it like you are currently, you are both blocking your application and using an insane amount of RAM depending on the number of pictures.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            H 1 Reply Last reply
            0
            • SGaistS SGaist

              You should write you own model and pixmap cache.

              Doing it like you are currently, you are both blocking your application and using an insane amount of RAM depending on the number of pictures.

              H Offline
              H Offline
              haris123
              wrote on last edited by haris123
              #6

              @SGaist

              Thank for the answer, right now I executing the above code from a thread, so no issue like GUI blocking. But as you pointed out the RAM usage getting higher for large number of image, there I may need to proceed with the solution you suggested. Do you have any reference regarding write my our model and pixmap cache.

              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