[PyQt] QSpinBox and setLineEdit

Mads Ipsen mpi at comxnet.dk
Fri Jan 30 15:00:01 GMT 2009


Yes, this will do the trick provided that the function you connect to does
not take to long to update. In that case the spin box jams or locks and does
several increments of its value. This is exactly why I want to connect to
the lineedit since this is first updated once the function you connect to
returns. I post a small cone snippet in a separate post that illustrates
this.

Mads

--------- Original Besked --------
Fra: Matt Smith <melkor at orangepalantir.org>
Til: Mads Ipsen <mpi at comxnet.dk>
Cc: pyqt at riverbankcomputing.com
Emne: Re: [PyQt] QSpinBox and setLineEdit
Dato: 30/01/09 15:15

> On Fri, 2009-01-30 at 14:55 +0100, Mads Ipsen wrote:
> &gt; import sys
> &gt; 
> &gt; from PyQt4 import QtCore, QtGui
> &gt;         
> &gt; def foo(text):
> &gt;     print 'valueChanged():', text
> &gt; 
> &gt; if __name__ == &quot;__main__&quot;:
> &gt;     app = QtGui.QApplication(sys.argv)
> &gt;     spin_box = QtGui.QSpinBox()
> &gt;     line_edit = spin_box.lineEdit()
> &gt;     line_edit.connect(line_edit, QtCore.SIGNAL('textChanged(const
> &gt; QString
> &gt; &amp;)'), foo)
> &gt;     spin_box.show()
> &gt;     sys.exit(app.exec_())
> 
> How about connecting to the spin box value changed?
> 
>  line_edit.connect(spin_box,QtCore.SIGNAL('valueChanged( int )'), foo)
> 
> I added that and it seems to do what you want.
> 


More information about the PyQt mailing list