PySide-QIntValidator::validate: Second tuple element is not convertible to unicode???????



  • Hi All,
    I wrote a custom Integer validator which basically allows user to add "%" at the end.
    When user enters certain integer value with combination "%" i have to strip and validate.

    but its giving following error:
    QIntValidator::validate: Second tuple element is not convertible to unicode???????

    can any one tell me what is wrong with the following code:
    @
    class LineEditValidator(QtGui.QIntValidator):
    def init(self,minimum,maximum,parent=None):
    QtGui.QIntValidator.init(self,minimum,maximum,parent)

    def validate(self,inputVal,pos):
    inputVal=inputVal.rstrip("%")
    inputVal=str(inputVal)
    if inputVal=="":
    return QtGui.QValidator.Invalid,inputVal,pos
    try:
    inputVal=inputVal.rstrip("%")
    inputVal=int(inputVal)
    except Exception,msg:
    return QtGui.QValidator.Invalid,inputVal,pos

    if inputVal >=self.bottom() and inputVal <=self.top():
      return QtGui.QValidator.Acceptable,inputVal,pos
    else:
      return QtGui.QValidator.Invalid,inputVal,pos
    

    @



  • sorry, my mistake i had to pass string type argument instead of int for 'inputVal' in
    return QtGui.QValidator.Invalid,inputVal,pos


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.