How to get values from the slider in pyside?

2019-02-27 11:14发布

问题:

Hello beautiful people,

I’m a total newbi in general gui and qt, and am kind of stuck. I downloaded the slider example from here [qt.gitorious.org] and sobered it down to just the sliders. The code I’ve got right now is as follows: http://pastebin.com/EkXxdPee

I now want to read the values from the slider and do stuff with it (send it over to another program using zeromq). I guess I have to do something with valueChanged, but I have no clue what. Could anybody help me out a little bit?

All tips are welcome!

[EDIT] Thanks to the answer of Romha Korev and some googling I found a full working example here: http://zetcode.com/gui/pysidetutorial/widgets/

I simply worked from there and I finally have what I want now. Thanks!

回答1:

Use the method value() to get the value in the QSlider.

slider = QtGui.QSlider()
slider.setValue( 5 )
print( slider.value() ) # Will print '5'