[英]Overload of QtGui.QLabel.setNum in PyQt4
In PyQt4, the slot QtGui.QLabel.setNum is overloaded. 在PyQt4中,插槽QtGui.QLabel.setNum重载。
We have setNum( int )
and setNum( float )
, linking to their c++ counterparts setNum( int)
and setNum( double)
. 我们有
setNum( int )
和setNum( float )
,它们链接到它们的c ++副本setNum( int)
和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. 不幸的是,似乎被称为
int
的插槽。
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? 有一种简单的方法可以强制调用setNum的float重载吗?
尝试使用另一种形式的connect
:
QtCore.QObject.connect(slider, QtCore.SIGNAL('setNum(double)'), <...>)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.