Try to use another form of connect
:
QtCore.QObject.connect(slider, QtCore.SIGNAL('setNum(double)'), <...>)
سؤال
In PyQt4, the slot QtGui.QLabel.setNum is overloaded.
We have setNum( int )
and setNum( float )
, linking to their c++ counterparts setNum( int)
and setNum( double)
.
I would like to connect a signal to the "float" version.
label = QLabel()
slider = QwtSlider()
slider.valueChanged[float].connect(label.setNum)
Unfortunately, the slot that seems to be called is the int
version.
My only workaround so far is
slider.valueChanged.connect(lambda x: label.setText(str(x)))
Is there a simple way to force the call of the float overload of setNum?
المحلول
Try to use another form of connect
:
QtCore.QObject.connect(slider, QtCore.SIGNAL('setNum(double)'), <...>)