Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide-QIntValidator::validate: Second tuple element is not convertible to unicode???????

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

Scheduled Pinned Locked Moved Language Bindings
2 Posts 1 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    ManasQt
    wrote on last edited by
    #1

    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
    

    @

    1 Reply Last reply
    0
    • M Offline
      M Offline
      ManasQt
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved