[RQt-devel] Question about validation with QLineEdit

Michael Lawrence lawrence.michael at gene.com
Sun Jul 11 03:09:01 CEST 2010


Just fixed it so that the return value is actually... returned. Guess that
was never tested. Anyway, btw, setting the text property directly will NOT
validate. You'll need to test by directly interacting with the widget.

Michael

On Sat, Jul 10, 2010 at 3:28 PM, John Verzani <verzani at math.csi.cuny.edu>wrote:

> 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
> _______________________________________________
> Qtinterfaces-devel mailing list
> Qtinterfaces-devel at lists.r-forge.r-project.org
>
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/qtinterfaces-devel/attachments/20100710/c8d4c63e/attachment.htm>


More information about the Qtinterfaces-devel mailing list