[PyKDE] QString and QValidator on Qt 4
Andreas Pakulat
apaku at gmx.de
Wed Nov 22 01:07:36 GMT 2006
On 22.11.06 00:32:22, Simon Edwards wrote:
> On Tuesday 21 November 2006 23:43, Andreas Pakulat wrote:
> > On 21.11.06 22:55:11, Simon Edwards wrote:
> > > I've come up against a problem in Qt 4 with QValidator and its fixup()
> method.
> > > This code working on Qt 3:
> > >
> > > def fixup(self,inputstr):
> > > return unicode(inputstr).replace(":","")
> > Things changed between Qt3 and Qt4 ;)
> > > But it doesn't seem to work like this on PyQt 4. PyQt4's fixup() seems to
> > > require no return value. Is in-place modification of the QString argument
> > > expected???
> > Yes, check the Qt4 docs, the fixup methods takes a reference to a
> > QString, so it can modify it without the need to return a new QString
> > object.
>
> I had a feeling that might be the case. But how can I neatly modify the
> contents of the QString object? QString doesn't have a setText() method.
Well, just remove the return. It should still work. At least this does
work with a pure python function. Because after all you get a reference
to a QString object in the fixup function. If you do anything to the
object there shouldn't be a copy created but the change should be done
to the original object.
Andreas
--
Your present plans will be successful.
More information about the PyQt
mailing list