[PyQt] Re: problem with connected scrollbars
Georg Altmann
george at george-net.de
Wed Nov 12 13:54:55 GMT 2008
Vicent Mas schrieb:
> Hi,
>
> thanks for your answer. I've been working about the TypeError and I've found
> that the call
>
> my_scrollbar.triggerAction(QtGui.QAbstractSlider.SliderSingleStepAdd)
>
> works
>
> but the (apparently equivalent) call
>
> my_scrollbar.triggerAction(1)
>
> fails raising the TypeError. However QAbstractSlider.SliderSingleStepAdd is
> supposed to have an integer value of 1, isn't it? At least this is what I
> understand when reading the Qt docs.
No, its an enum. It looks like int is not implicitly converted to the
required enum type. Interesting. Probably there is more info in the SIP
docs.
>>> from PyQt4.QtGui import *
>>> type(QAbstractSlider.SliderSingleStepAdd)
<class 'PyQt4.QtGui.SliderAction'>
>>> a = QAbstractSlider.SliderAction(1)
>>> type(a)
<class 'PyQt4.QtGui.SliderAction'>
>>> a == QAbstractSlider.SliderSingleStepAdd
True
So I think
my_scrollbar.triggerAction(QAbstractSlider.SliderAction(1))
will do what you want.
> Even more, the actionTriggered SIGNAL passes integer values to the slot it is
> connected. So I supposed that I could use this values directly for triggering
> the same action in other scrollbar, but I cannot. Instead the constants names
> have to be used. Could you (or somebody else :-) tell me why?
Make sure your 'values' have the correct type - see above.
Regards
Georg
More information about the PyQt
mailing list