[PyQt] QLineEdit with QRegExpValidator doesn't emit returnPressed signal

Sergio Daniel Gomez sergiogomez at tostado.com.ar
Sat Feb 28 10:08:49 GMT 2009


Filip Gruszczyński escribió:
> I have following app:
> 
> import sys
> 
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> 
> def foo():
> 	print "foo"
> 
> app = QApplication(sys.argv)
> 
> edit = QLineEdit()
> expression = QRegExp('((\d)+(-(\d)+)?\,( )?)+')
Tray change the QRegExp

QRegExp('((\d)+(-(\d)+)?\,?( )?\r?)+')



> edit.setValidator(QRegExpValidator(expression, edit))
> 
> app.connect(edit, SIGNAL('returnPressed()'), foo)
> edit.show()
> 
> app.exec_()
> 
> 
> When I type something into the edit (it accepts things like 1,2,3-5,
> which means number or ranges (represented by x-y) seperated by comas)
> and hit enter nothing happens. How can I make it emit this signal?
> 



More information about the PyQt mailing list