Question

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?

Was it helpful?

Solution

Try to use another form of connect:

QtCore.QObject.connect(slider, QtCore.SIGNAL('setNum(double)'), <...>)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top