Need some advise with thumbnails and loading image
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.
Re: Need some advise with thumbnails and loading image
You can maintain a list of sort -
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.
Re: Need some advise with thumbnails and loading image
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.
Code:
void XXX
::setImage(const QString &file
) {
QPixmap thumb
= /*generate thumb of file*/ m_myFilePath = file;
}
QString XXX
::originalFileName() const {
return m_myFilePath;
}