Results 1 to 2 of 2

Thread: need help with photo gallery

  1. #1
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question need help with photo gallery

    Hi everyone,
    Am working on a photo gallery created using Qt 3.3
    I am displaying the selected picture on a Label.
    The thing is,the label has a height and width of say 900 and 600 but,the selected picture has a height and width of 700,400.
    When the picture is displayed on the label,multiple copies of the picture cover the whole of the label(no empty space on the label)
    I want that only one copy of the picture(of ht/width 700/400) should appear on the label and the remaining vacant space on the text label should remain the way it is.
    Please give me some idea of how to do that.
    Thanks.

  2. #2
    Join Date
    May 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: need help with photo gallery

    Although I am not that familiar with Qt, I think there is a function for scaling images in labels.

    Qt Code:
    1. QImage image(filePath); //Have a QImage read in the image from a certain file
    2.  
    3. ui->labelForImage->setScaledContents(false); //Make the label not scale the picture
    4. ui->labelForImage->setAlignment( Qt::AlignCenter ); //Alignthe picture in the middle of the label
    5.  
    6. ui->labelForImage->setPixmap(QPixmap::fromImage(image)); //Put the picture into the label
    To copy to clipboard, switch view to plain text mode 

    The one issue I can think of for this is that if the picture is larger than the label, the label will expand. I am not sure how to get around this though.

    Anyway, I hope this helps. Cheers.

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
  •  
Qt is a trademark of The Qt Company.