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.<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>
<div class="im">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>
</div>_______________________________________________<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>
</blockquote></div><br>