Sure, the methods I already posted are more or less like those are in my code. The only difference is that imageReady and the slot imageGenerated accept two parameters instead of one. I didn't report the implementation of imageGenerated which is this:
Class* item = itemsMap.value(string);
item->setImageLoaded(image);
}
void Class2::imageGenerated(QImage image, QString string) {
Class* item = itemsMap.value(string);
item->setImageLoaded(image);
}
To copy to clipboard, switch view to plain text mode
where Class2 is a subclass of QGraphicsScene and itemsMap is a QMap which maps strings to objects of class Class. Sorry I made a mistake in the other post, in fact IconViewItem was Class.
This method I reported calls the method setImageLoaded of class Class that I reported above (it was complete, it only lacked another assignation of image, no more lines).
Of course the connect statement was:
connect(loader, SIGNAL(imageReady(QImage, QString)), this, SLOT(imageGenerated(QImage, QString)));
To copy to clipboard, switch view to plain text mode
The code I reported for the worker thread was complete, I only removed some lines where I set the size I want for imageReader before loading (I report in case it's relevant):
QImageReader imageReader
(dir
->absoluteFilePath
(filesList
->at
(i
)));
if (imageReader.size().height() >= imageReader.size().width())
imageReader.
setScaledSize(QSize(imageReader.
size().
width()*64/imageReader.
size().
height(),
64));
else imageReader.
setScaledSize(QSize(64, imageReader.
size().
height()*64/imageReader.
size().
width()));
QImageReader imageReader(dir->absoluteFilePath(filesList->at(i)));
if (imageReader.size().height() >= imageReader.size().width())
imageReader.setScaledSize(QSize(imageReader.size().width()*64/imageReader.size().height(), 64));
else imageReader.setScaledSize(QSize(64, imageReader.size().height()*64/imageReader.size().width()));
To copy to clipboard, switch view to plain text mode
where dir and filesList are local pointers to QDir and QStringList respectively.
Bookmarks