0

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?

Quant
  • 1,593
  • 14
  • 21

1 Answers1

1

Try to use another form of connect:

QtCore.QObject.connect(slider, QtCore.SIGNAL('setNum(double)'), <...>)
Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127
  • Unfortunately, using your approach seems to give the same result. More precely, I wrote: QtCore.QObject.connect(self.ui.Slider, QtCore.SIGNAL('valueChanged (double)'), self.ui.label_2, QtCore.SLOT('setNum (double)')) and I am still getting integers. – Quant Jun 19 '13 at 23:20