tags:

views:

33

answers:

1

I have simple QlistWidget that im loading images in one call using this code :

ui.listWidgetImages->setIconSize(QSize(60, 60));
QStringList::const_iterator i = filenames.constBegin(); // QStringList that holds the images paths
while (i != filenames.constEnd()) {
  QString value = *i;
  QListWidgetItem *standardItemnew = new QListWidgetItem(value, ui.listWidgetImages);
  standardItemnew->setIcon(QIcon(value));    
  ++i;         
}

i guess the slowleness it the result of scalling down the images to 60 / 60 size
but it there any way to speed the process ?

A: 

The fastest soluton would be to pre-generate the thumbnails or use thumbnails already embedded in the image.

If that's not feasible your only option may be to us Qt's multithreading. There are two sides to this. To start with the entire task of populating the list could be hived off into a separate thread so that the application doesn't lock during the process. More ambitiously, if the users have multi-core systems you might consider loading and scaling each image in a separate thread.

Simon Hibbs
what is : "...thumbnails already embedded in the image.."?and the loading images are random all the time
Some image formats allow for embedded thumbnail images, particularly TIFF and EXIF (see Wikipedia).
Simon Hibbs
again this is not an option ,is this is the only way ?