Python, PyQT and QSpinBox

Boudewijn Rempt boud at rempt.xs4all.nl
Sun Dec 2 03:16:36 EST 2001


Yngve F. Johansen <yfjohans at nospamthankyoumam-siving.hia.no> wrote:
> Hello

> I'm rather new to Python, and to GUI programming as well. I've been fooling
> around with the QT toolkit, and find it extremely easy and intuitive to work
> with, short of one thing I can't figure out:

> I use a QSpinBox in my dialog, and it works, kind of. The problem is when I
> enter text rather than use the Up/Down buttons. The text isn't 
> updated/converted
> to an integer-value automatically, but if I move the mouse-pointer over the
> widget buttons it gets converted.

> Is there a way to change this behavior? I've tried to subclass the QSpinBox 
> and
> write my own functions, but it didn't help a whole lot.

Which version of Qt are you using? The Qt 3 QSpinbox has a function
interpretText() that should be called whenever the user manually edits
the contents of the spinbox. I think that this function should do the
right thing by default (i.e. call mapTextToValue(), but you could
always subclass QSpinbox and reimplement interpretText to do what you
want.

If you could post a small sample script showing the behaviour, I'm sure
I cold help you find a solution.


-- 

Boudewijn Rempt  | http://www.valdyas.org 



More information about the Python-list mailing list