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

Filip Gruszczyński gruszczy at gmail.com
Fri Feb 27 20:56:41 GMT 2009

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)+)?\,( )?)+')
edit.setValidator(QRegExpValidator(expression, edit))

app.connect(edit, SIGNAL('returnPressed()'), foo)


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?

Filip Gruszczyński

More information about the PyQt mailing list