[PyKDE] QValidator.fixup() and PyQt
Jonathan Gardner
jgardn at alumni.washington.edu
Mon Feb 24 21:33:01 GMT 2003
I am trying to implement my own QValidator so that I can do cool things like
enter money, phone numbers, etc...
Anyway, I would like to be able to modify the QString passed into fixup().
However, the code below (obviously) doesn't work.
# Begin code
import sys
from qt import *
class validator(QValidator):
def __init__(self, parent=None, name=None):
QValidator.__init__(self, parent, name)
def validate(self, input, pos):
return (QValidator.Intermediate, pos)
def fixup(self, input):
# How to do an in-place modification of input?
input = QString("no!")
class test_validator(QWidget):
def __init__(self, parent=None, name=None, fl=0):
QWidget.__init__(self, parent, name, fl)
lo = QVBoxLayout(self, 11, 6)
self.le = QLineEdit(self)
self.le.setValidator(validator(self.le))
lo.addWidget(self.le)
if __name__ == "__main__":
app = QApplication(sys.argv)
args = app.argv()
QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()"))
w = test_validator()
app.setMainWidget(w)
w.show()
app.exec_loop()
# End code
This method above doesn't work. I need a way to modify 'input' so that fixup
can actually do something.
Any ideas?
Or should I be returning the the value like it does for other functions that
accept a C++ '&' parameter? (And since PyQt doesn't handle this... is it a
bug?)
--
Jonathan Gardner
jgardn at alumni.washington.edu
Python Qt perl apache and linux
More information about the PyQt
mailing list