Page 1 of 1

AlphaNumeric input hint

Posted: Mon Jul 20 2020 7:54 pm
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

Re: AlphaNumeric input hint

Posted: Sat Jul 25 2020 7:32 am
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]*") );

Re: AlphaNumeric input hint

Posted: Wed Nov 17 2021 12:11 pm
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

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.