Qt label image display always has different size from original image
-
I have a problem with the image size displayed on label. It seems there are a fixed maximum size for the image's height even when the displayed image should be larger (check image below). This resulted the image getting cut which I don't want. I already tried to change the size of the Qpixmap ratio but the one that change is the size of the image but not the frame of the image. Here is the code that I use to display the image
from PyQt5 import QtWidgets,QtGui,QtCore from mainwindow import Ui_MainWindow import numpy as np import sys import cv2 import matplotlib.pyplot as plt class ApplicationWindow(QtWidgets.QMainWindow): def __init__(self): super(ApplicationWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.extractLightbtn.clicked.connect(lambda:self.extractLight(self.ui.browseLine.text())) def extractLight(self,filePath): #function to do extraction using model if filePath != "": self.oriImage = QtGui.QPixmap(filePath) self.oriResImage = self.oriImage.scaled(256, 256, QtCore.Qt.KeepAspectRatio) self.ui.oriDisplay.setPixmap(self.oriResImage)
As you can see on screenshot above. The right image got cut on neck to below and What I want is to display it to the same size as the image on the left. The original image size is 178x218 and since I allocate 256x256 space it should be enough for it. I do suspect the problem is on the designer part. Maybe someone can give me guidance on how to build it, I would be grateful