October 5, 2011

ManasQt ManasQt
Lab Rat
38 posts

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:

  1.  
  2. class LineEditValidator(QtGui.QIntValidator):
  3.   def __init__(self,minimum,maximum,parent=None):
  4.       QtGui.QIntValidator.__init__(self,minimum,maximum,parent)
  5.        
  6.   def validate(self,inputVal,pos):
  7.     inputVal=inputVal.rstrip("%")
  8.     inputVal=str(inputVal)
  9.     if inputVal=="":
  10.       return QtGui.QValidator.Invalid,inputVal,pos
  11.     try:
  12.       inputVal=inputVal.rstrip("%")
  13.       inputVal=int(inputVal)
  14.     except Exception,msg:
  15.       return QtGui.QValidator.Invalid,inputVal,pos
  16.      
  17.     if inputVal >=self.bottom() and inputVal <=self.top():
  18.       return QtGui.QValidator.Acceptable,inputVal,pos
  19.     else:
  20.       return QtGui.QValidator.Invalid,inputVal,pos

1 reply

October 5, 2011

ManasQt ManasQt
Lab Rat
38 posts

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

 
  ‹‹ Phonon + QBuffer      QStandardItem - parent-child with multiple columns ››

You must log in to post a reply. Not a member yet? Register here!