PDA

View Full Version : need help with photo gallery



rishiraj
7th January 2009, 14:13
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.

weevle123
9th May 2010, 06:05
Although I am not that familiar with Qt, I think there is a function for scaling images in labels.




QImage image(filePath); //Have a QImage read in the image from a certain file

ui->labelForImage->setScaledContents(false); //Make the label not scale the picture
ui->labelForImage->setAlignment( Qt::AlignCenter ); //Alignthe picture in the middle of the label

ui->labelForImage->setPixmap(QPixmap::fromImage(image)); //Put the picture into the label




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.