views:

72

answers:

1

I am trying to imple QLineEdit's text which is all capital letters no matter what user types in. I have found several solutions, none of them working in Ruby. In brief I have QLineEdit object searchEdit and this code:

class UpcaseValidator < Qt::Validator
   def validate(input,pos)
     input.upcase!
     Qt::Validator::Acceptable
   end
end
...
def initialize(parent = nil)
  uppercaseValidator = UpcaseValidator.new;
  searchEdit.setValidator(uppercaseValidator)
...

The validate method gets triggered correctly whenever user types in the input field, but it is not getting uppercased. Seems to me that changing input variable within validate does not get propagated back to the searchEdit object.

Thanks for any help, even pointing me out to some good docs about Qt Ruby bindings.

A: 

QValidator has a method called 'fixup()', which will probably do what you want :)

LiraNuna
I have seen this one - however it only fixes the contents when the Enter is pressed and secondly, it does not work in qtruby at all :-(
gorn