[RQt-devel] Question about validation with QLineEdit

Michael Lawrence lawrence.michael at gene.com
Sun Jul 11 01:20:55 CEST 2010


Went ahead and added QString& -> character version. But note that it's not
possible to modify the string in place, as it would be in C++. Not sure I
see the point in that method, but it would be necessary in
QValidator::fixup(). Non-const reference parameters are rare in the Qt API,
so support for 'out' parameters has not been implemented. I'm guessing the
logic could be that if the method returns 'void', any return value from R
should be interpreted as the new value for the QString& parameter. If the
function were non-void, or if there were multiple out parameters, a list
would be returned.

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/9ab010a8/attachment.htm>


More information about the Qtinterfaces-devel mailing list