[PyQt] [pyqt]how to reimplement qvalidator.validate() in api v2?
Phil Thompson
phil at riverbankcomputing.com
Mon Jul 29 11:16:09 BST 2013
On Mon, 29 Jul 2013 18:09:17 +0800, Han Jiang <oglops at gmail.com> wrote:
> The code works fine in api v1, if i uncomment the top sip calls, then it
> means i'll be using v2, then of course i'll see errors like
>
> TypeError: invalid result type from Validator.validate()
>
> i know i need to change the return value of .validate() , but if i
change
> it to what pyqt doc says in v2 ,
> http://pyqt.sourceforge.net/Docs/PyQt4/qvalidator.html#validate-2 ,it
gives
> me segmentation fault ( on pyqt 4.6.1, centos 6.3 x64). why?
>
> v2 code works fine on pyqt 4.8 and 4.10 though ( tested on a fedora 19
> linux and a windows 7 machine.) is this a bug or what am i missing ?
>
> thanks !
>
> http://pastebin.com/dDeZ52gZ
>
>
>
> #!/usr/bin/env python2
>
> # api v2
> import sip
> sip.setapi('QString', 2)
> sip.setapi('QVariant', 2)
>
> from PyQt4.QtGui import *
> from PyQt4.QtCore import *
> import re,os,sys
>
> class MyQComboBox(QComboBox):
> def __init__(self, parent=None, listing=None):
> super(MyQComboBox, self).__init__(parent)
>
> if listing != None:
> self.listSetup(listing)
>
> def listSetup(self, listing):
> self.setEditable(True)
If code doesn't work on an early version but works on a later version then
it's fairly safe to assume there is a bug in the early version.
Phil
More information about the PyQt
mailing list