[PyKDE] Cannot derive QValidator

Phil Thompson phil at riverbankcomputing.co.uk
Tue Dec 6 11:29:09 GMT 2005


On Tuesday 06 December 2005 11:12 am, Giovanni Bajo wrote:
> Hey,
>
> there seems to be a problem inheriting QValidator:
>
> =======================
> from qt import *
> app = QApplication([])
>
> class V(QValidator):
>     def validate(self, index, pos):
>         return QValidator.Valid
> v = V(None)
>
> cb = QComboBox(None)
>
> cb.setEditable(True)
> cb.setValidator(v)
>
> cb.show()
> app.setMainWidget(cb)
> qApp.exec_loop()
> =======================
>
> any time I press a key, I see:
>
> ========================
> TypeError: invalid result type from V.validate()
> ========================
>
> This is with PyQt 3.15, SIP 4.3.1.

The Python signature is different to the C++ signature - check the 
documentation.

Phil




More information about the PyQt mailing list