Python, PyQT and QSpinBox

Yngve F. Johansen yfjohans at NOSPAMTHANKYOUMAM-siving.hia.no
Sun Dec 2 08:44:45 EST 2001


Boudewijn Rempt wrote:

> 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.

I've got QT v2.3.1 installed, and if I'm not mistaken the interpretText()
function is available in QT 2.3 as well, it's at least listed in the
documentation. When I subclassed QSpinBox I overwrote mapTextToValue, and 
simply tried to convert a string to an integer which I returned. I also 
reimplemented textChanged() and simply called updateDisplay(). The problem 
seems to be that there isn't any signaling going on until I move my 
mousepointer over the widget, as none of my overwritten functions are 
called unless I do so.

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

I don't really know if there is any point in pasting any code, as I don't 
have much code related to the QSpinBox. I originally used the raw QSpinBox 
widget and it worked, short of it not updating the value unless I move my 
mouse over it. I'm not using any weird values either, just integers from 0 
to 99.

I'm not to familiar with the signal-slot mechanism, and it could be that I 
have to do something with this? I don't have a single connect() statement 
defined relating to the QSpinBox widget.

Hope you have some tips, thanks for your help thus far!

Sincerly,
Yngve F. Johansen



More information about the Python-list mailing list