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.<br>
<br>Michael<br><br><div class="gmail_quote">On Sat, Jul 10, 2010 at 3:28 PM, John Verzani <span dir="ltr"><<a href="mailto:verzani@math.csi.cuny.edu">verzani@math.csi.cuny.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I know I can do this a different way, but was thinking this should work:<br>
<br>
library(qtbase)<br>
<br>
qsetClass("positiveValidator", Qt$QValidator, function(parent = NULL) {<br>
super(parent)<br>
})<br>
<br>
qsetMethod("validate", positiveValidator, function(input, pos) {<br>
val <- as.integer(input) > 0<br>
if(val)<br>
return(Qt$QValidator$Acceptable)<br>
else<br>
return(Qt$QValidator$Invalid)<br>
})<br>
<br>
<br>
e <- Qt$QLineEdit()<br>
v <- positiveValidator(e)<br>
e$setValidator(v)<br>
<br>
e$text=-1<br>
<br>
## Gives this error:<br>
Error in e$text = 1 :<br>
Cannot convert argument of type 'QString&' to SEXP in<br>
R::.GlobalEnv::positiveValidator::validate<br>
<br>
<br>
I guessing there is a conversion that needs to take place, but it<br>
seems like it should happen prior to the<br>
call to the validate method.<br>
<br>
Any help is appreciated. --John<br>
<br>
<br>
--<br>
<font color="#888888">John Verzani<br>
Chair, Department of Mathematics<br>
College of Staten Island, CUNY<br>
<a href="mailto:verzani@math.csi.cuny.edu">verzani@math.csi.cuny.edu</a><br>
_______________________________________________<br>
Qtinterfaces-devel mailing list<br>
<a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
</font></blockquote></div><br>