Results 1 to 3 of 3

Thread: Need some advise with thumbnails and loading image

  1. #1
    Join Date
    May 2008
    Location
    USA
    Posts
    22
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Need some advise with thumbnails and loading image

    You can maintain a list of sort -
    Qt Code:
    1. QList < QLabel* /*thumbnail pointer*/, QString /*filename*/> tumbNailList;
    To copy to clipboard, switch view to plain text mode 
    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default 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.

    Qt Code:
    1. void XXX::setImage(const QString &file)
    2. {
    3. QPixmap thumb = /*generate thumb of file*/
    4. QLabel::setPixmap(thumb);
    5. m_myFilePath = file;
    6. }
    7.  
    8. QString XXX::originalFileName() const
    9. {
    10. return m_myFilePath;
    11. }
    To copy to clipboard, switch view to plain text mode 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.