Recently I'm learning to use PyQt4
, but I've had a question about using the line of code to modify the scale of an image:
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(743, 510)
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(20, 430, 85, 27))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.foto = QtGui.QLineEdit(Form)
self.foto.setGeometry(QtCore.QRect(20, 390, 700, 27))
self.foto.setObjectName(_fromUtf8("Diretorio"))
self.label = QtGui.QLabel(Form)
self.label.setGeometry(QtCore.QRect(30, 26, 671, 341))
self.label.setText(_fromUtf8(""))
self.label.setObjectName(_fromUtf8("label"))
self.horizontalSlider = QtGui.QSlider(Form)
self.horizontalSlider.setGeometry(QtCore.QRect(120, 430, 601, 18))
self.horizontalSlider.setMaximum(255)
self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
self.horizontalSlider.setObjectName(_fromUtf8("horizontalSlider"))
self.label_2 = QtGui.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(380, 450, 71, 17))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.retranslateUi(Form)
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.abrirfoto)
#self.horizontalSlider.valueChanged.connect(self.threshold)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Testando", None))
self.pushButton.setText(_translate("Form", "Abrir", None))
self.label_2.setText(_translate("Form", "Threshold", None))
def abrirfoto(self):
img = self.foto.text()
self.label.setPixmap(QtGui.QPixmap(img))
QtGui.QPixmap.scaled(671,341,0,0)
And returns error:
TypeError: arguments did not match any overloaded call: QPixmap.scaled (int, int, Qt.AspectRatioMode aspectRatioMode = Qt.IgnoreAspectRatio, Qt.TransformationMode transformMode = Qt.FastTransformation): first argument of unbound method must have type 'QPixmap' QPixmap.scaled (QSize, Qt.AspectRatioMode aspectRatioMode = Qt.IgnoreAspectRatio, Qt.TransformationMode transformMode = Qt.FastTransformation): first argument of unbound method must have type 'QPixmap'