[RQt-devel] Question about validation with QLineEdit

John Verzani verzani at math.csi.cuny.edu
Sun Jul 11 04:58:23 CEST 2010


Thanks for both fixing this and saving me my next question ;) --John

On Sat, Jul 10, 2010 at 9:09 PM, Michael Lawrence
<lawrence.michael at gene.com> wrote:
> 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
>
>



-- 
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