1 Attachment(s)
Problem with displaying image using Qlabel
Hi........
I have a problem while displaying an image in label. when u simply open l.png its image display is horizontal but when u open with code display is in vertical. i want the image as it is seen in simply opening and no scrollbar should come full image should be displayed on the label with no scollbars.
Code:
imageLabel
->setBackgroundRole
(QPalette::Base);
imageLabel->setScaledContents(true);
scrollArea
->setBackgroundRole
(QPalette::Dark);
scrollArea->setWidget(imageLabel);
setCentralWidget(scrollArea);
setWindowTitle(tr("Image Viewer"));
resize(800, 900);
QImage image
("/home/karl/Desktop/l.tif");
imageLabel
->setPixmap
(QPixmap::fromImage(image
));
scaleFactor = 1.0;
scrollArea->setWidgetResizable(1);
Re: Problem with displaying image using Qlabel
I dont quite understand! If you don't want scrollbars, then don't put your label into a scrollarea. setScaledContents should scale your pixmap to fit the labels size.
As to the rotation: Could it be that your image viewer automatically rotates the file due to some meta information e.g. xmp or exif orientation? Because I don't think that QLabel will rotate the image by itself.
Try an image from a different source.
HIH
Joh