I have the following code, that loads an image from disk and tries to scale it down to 30 x 30. Later i add the label to a gridlayout. Unfortunately the image is not being scaled down to the intended size so all my cells in the grid layout have diferent sizes.
pixmap = QtGui.QPixmap(filename)
pixmap.scaled(QtCore.QSize(30,30), QtCore.Qt.KeepAspectRatio, QtCore.Qt.FastTransformation)
self.L.append(pixmap)
lbl = QtGui.QLabel(self)
lbl.setPixmap(pixmap)
lbl.setScaledContents(True)
column=len(self.L)
self.ui.gridLayout.addWidget(lbl,0,column,Qt.AlignLeft | Qt.AlignTop)
Are you sure that
pixmap.scaleddoes an in-place transformation of the image? I would have expected it to return a new, scaled, image – assign that to a variable and use it instead.According to this documentation:
So, I guess you should be doing: