AlphaNumeric input hint

Post Reply
seasoned_geek
Posts: 254
Joined: Thu Jun 11 2020 12:18 pm

AlphaNumeric input hint

Post by seasoned_geek »

It would be nice if we could get an AlphaNumeric input hint. Something that would only allow letters and numbers. No spaces or punctuation. Would not care about upper or lower case.

Code: Select all

    //  TODO:: Really need to get an AlphaNumeric hint added
    destName = QInputDialog::getText(this, "New Theme name", "Name: ", QLineEdit::Normal,
                                     destName, &okFlag, Qt::Dialog, Qt::ImhNone);
Right now I think we have to create our own validator to do such a thing. Be much nicer if the hint could just do that for us.

Yes, I want some cheese for my whine. :P
barbara
Posts: 446
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: AlphaNumeric input hint

Post by barbara »

We traced through the code for QInputDialog::getText() and these are hints which are intended to be
processed in the platform plugin. A few of the hints are handled for cocoa but none of them are processed on windows or xcb.

From our research the purpose of QInputMethod (which is the class that handles the hint) was designed to deal with configuring a virtual keyboard. For a desktop application the proper way to constrain input or use a mask is with a validator.

For a line edit you can use QLineEdit::setInputMask() or QLineEdit::setValidator(). Here is a a quick example that will work in CopperSpice.

Code: Select all

// any alpha char, any number
auto regex = new QRegularExpressionValidator( QRegularExpression("[\\d\\l\\u]*") );
lineEdit->setValidator(regex); 
Barbara
seasoned_geek
Posts: 254
Joined: Thu Jun 11 2020 12:18 pm

Re: AlphaNumeric input hint

Post by seasoned_geek »

I know this is an old thread, but today's "desktop" applications are running on tablets, 2-in-one's, kiosks, and all-in-one computers where people do not use the keyboard. Many embedded devices running Linux need to have virtual keyboards as well.

One of the bigger selling points for Qt commercial is the multi-lingual virtual keyboards.

Please add to the ever growing requested feature list XML driven virtual keyboards. Something along the lines of the matchbox keyboards

https://github.com/mwilliams03/matchbox-keyboard

On a tiny screen the Mandarin language gets really wonky. You end up having a multi-tiled keyboard that requires about 3 taps to get to the symbol one needs.
Post Reply