[Interest] QLineEdit upper case
pmqt71 at gmail.com
Fri Aug 8 18:08:14 CEST 2014
I have a base class for dialogs, QxDialog, where I'd like to manage the
upper case input for all contained QLineEdits.
Some of them, in the derived dialog, already have a validator for other
purposes (email, postal code...).
if the user type 'a' the event text should be translated in 'A'. So I'm
trying to ignore the event and re-post it in uppercase.
yes my problem is that QLineEdit can have only 1 validator. I think
inherithance should be easier than implementin a ChainValidator, am I right?
2014-08-08 17:47 GMT+02:00 Bo Thorsen <bo at vikingsoft.eu>:
> You don't have to modify it. Just filter it out if it's one you don't want
> to to allow the lineedit to receive.
> Den 08-08-2014 16:54, pmqt71 skrev:
>> Hi Bo,
>> as I said, some controls already have a validator so I can't replace it.
>> I also tried the event filter, but once intercepted, the event is not
>> modifiable :
>> if (event->type() == QEvent::KeyRelease)
>> QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
>> // keyEvent has no method to change the key!
>> 2014-08-08 15:48 GMT+02:00 Bo Thorsen <bo at vikingsoft.eu
>> <mailto:bo at vikingsoft.eu>>:
>> Den 08-08-2014 15:41, pmqt71 skrev:
>> > Hi,
>> > I need a QLineEdit control that forces user input in uppercase
>> > editing, not after loosing the focus.
>> > I'm trying different ways but each has side effects:
>> > - using the textEdited signal to make the text upper : bad
>> behaviour if
>> > editing in the middle;
>> > - using a validator : dislike this solution because some
>> QLineEdit have
>> > their validator.
>> > Is there a simple way?
>> The validator is the simple way.
>> For completeness, you could also do a subclass or event filter that
>> filters out all keyboard events with lower case letters.
>> But I would go with the validator.
>> Viking Software
>> Qt and C++ developers for hire
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
> Viking Software
> Qt and C++ developers for hire
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest