[kde-guidelines] Styleguide: Unconstrained input

Aurélien Gâteau agateau at kde.org
Mon Jun 24 15:27:05 UTC 2013


On Sunday 23 June 2013 14:17:06 Heiko Tietze wrote:
> Am Samstag, 22. Juni 2013, 22:01:55 schrieb Aurélien Gâteau:
> > The widget to enter one line of text is called KLineEdit. The widget to
> > enter multiple line of texts is called KTextEdit.
> 
> Thanks. Because both are called "edit" I used
> http://techbase.kde.org/Projects/Usability/HIG/edits for the proposal but
> refered to it by "To enter one line of text use a line edit and for multiple
> lines of texts a text edit."
> 
> Thomas' remarks are included.
> 
> I wonder how we handle formatted input. As far as I have seen there are some
> controls available for unconstrained input. My preliminary structure has
> two further bullet points: "Lists with direct input" and "Complex views
> with direct input (Grid cell editing)"

>From a developer point of view, there are two ways to define formatted input, 
both use KLineEdit.

First way is to define an input mask [1]. This is a string which describes 
allowed characters. For example, if the mask is set to "9999" then the user 
must enter 4 digits.

Second way is to assign a validator to the KLineEdit. A validator is a piece 
of code which checks if the entered text is valid. Qt ships with validators 
checking if the input is an integer, a floating-point number or if it matches 
a regular expression. The developer can also opt to write his own validator.

KLineEdit does not provide any feedback to the user regarding validity of the 
text. KLineEdit does not allow the user to type a character which does not 
match the mask or would make the validator consider the text invalid.

When using a mask, KLineEdit can present placeholders for characters.

Aurélien

[1]: http://qt-project.org/doc/qt-4.8/qlineedit.html#inputMask-prop


More information about the kde-guidelines mailing list