[RQt-devel] Question about validation with QLineEdit

John Verzani verzani at math.csi.cuny.edu
Sun Jul 11 00:28:53 CEST 2010


I know I can do this a different way, but was thinking this should work:

library(qtbase)

qsetClass("positiveValidator", Qt$QValidator, function(parent = NULL) {
  super(parent)
})

qsetMethod("validate", positiveValidator, function(input, pos) {
  val <- as.integer(input) > 0
  if(val)
    return(Qt$QValidator$Acceptable)
  else
    return(Qt$QValidator$Invalid)
})


e <- Qt$QLineEdit()
v <- positiveValidator(e)
e$setValidator(v)

e$text=-1

## Gives this error:
Error in e$text = 1 :
  Cannot convert argument of type 'QString&' to SEXP in
R::.GlobalEnv::positiveValidator::validate


I guessing there is a conversion that needs to take place, but it
seems like it should happen prior to the
call to the validate method.

Any help is appreciated. --John


-- 
John Verzani
Chair, Department of Mathematics
College of Staten Island, CUNY
verzani at math.csi.cuny.edu


More information about the Qtinterfaces-devel mailing list