Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

To Reduce loading time of Images Large Images



  • Hi,

    1. I am loading large images of size 2MB in a ListView of QML.Still Images glitter.
      If I reduce the size to 40KB then there is no glittering. So how can I remove glittering even if the size is 2MB.

    2. I want to Reduce Loading time, should I use QImageReader along with QQuickImageProvider

    Have gone through Qt Doc...... Performance Considerations And Suggestions and have met them

    below is the code

    void StatisticsImageProvider::run()
    {

    QString separator ="";
    QString textDelimiter = ",";
    CsvFileHandler::GetInstance()->processData(IMAGE_LIST_CSV_FILE,separator, textDelimiter);
    QStringList list=CsvFileHandler::GetInstance()->getListOfImageKeys();
    QString dirpath=QGuiApplication::applicationDirPath() + "/../Resources/image/TotalImages/"; 
    for(int i=0;i<list.length();++i){
       QString path=dirpath+list.at(i)+".png";
       QPixmap map;
       map.load(path);
        map.scaled(253,250);
       map_Pixmap.insert(list.at(i),map);
    }
    

    }

    QPixmap StatisticsImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
    {
        QPixmap map(map_Pixmap.value(id));
        return map;
    }
    

  • Lifetime Qt Champion

    Hi,

    As soon as you use QImage or QPixmap, you'll use QImageReader. QQuickImageProvider allows you to pass whatever image you want to your QtQuick GUI. Whether it's a generated or loaded image doesn't matter.

    If you have a set of large images, you should rather consider creating thumbnails that loads quickly and only load the full resolution images on demand.


Log in to reply