PDA

View Full Version : Need some advise with thumbnails and loading image



nmuntz
8th June 2009, 22:23
Hi All,

I have a QHBox with a Custom Widget that inherits QLabel which iterates through all image files in a folder and generates a thumbnail.

This is working fine, however I need to implement the functionality to display the original image from where the thumbnail was generated.
What would be the best way of doing this? Right now the clicked() signal is only displaying the QPixmap from the QLabel, what I need it to do is load the original full size image.

I'm guessing I will need a list of some sort but how would I reference each image to its unique key from the list?

Please advise me on how would I go about implementing this as I feel i'm a bit lost.
Thank you in advance for your help.

aamer4yu
9th June 2009, 05:22
You can maintain a list of sort -

QList < QLabel* /*thumbnail pointer*/, QString /*filename*/> tumbNailList;
When a label is clicked you can get the file name from the list and load the full image and show in some other label/window.

Lykurg
9th June 2009, 14:32
You can also reconsider to use a graphic scene for that thumbnail list, which would be not so expensive. (Then you coud use setData() with user role)

But for your solution, simply add a member variable to your widget which inherits the label.


void XXX::setImage(const QString &file)
{
QPixmap thumb = /*generate thumb of file*/
QLabel::setPixmap(thumb);
m_myFilePath = file;
}

QString XXX::originalFileName() const
{
return m_myFilePath;
}