MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QML TextField Element

The TextField element displays a single line of editable plain text More...

This element was introduced in qt-components 4.7.

Properties

Methods

Detailed Description

TextField is used to accept a line of text input. Input constraints can be placed on a TextField item (for example, through a validator or inputMask), and setting echoMode to an appropriate value enables TextInput to be used for a password input field.

 TextField {
     placeholderText: "Default text"
     maximumLength: 80
 }

 TextField {
     text: "read only text field"
     readOnly:  true
 }

Property Documentation

acceptableInput : bool

This property is always true unless a validator or input mask has been set. If a validator or input mask has been set, this property will only be true if the current text is acceptable to the validator or input mask as a final string (not as an intermediate string).


cursorPosition : int

The position of the cursor in the TextField.


customSoftwareInputPanel : Component

Replaces the default software input panel with your own.


echoMode : enumeration

Specifies how the text should be displayed in the TextField.

  • TextInput.Normal - displays the text as it is (default).
  • TextInput.Password - displays asterisks instead of characters.
  • TextInput.NoEcho - displays nothing.
  • TextInput.PasswordEchoOnEdit - displays all but the current character as asterisks.

enableSoftwareInputPanel : bool

Disables the default software input panel. Enabled by default.


errorHighlight : bool

Allows you to show error highlight for the TextField.

Usage for mandatory field:

 TextField {
     //...
     errorHighlight: !acceptableInput
     validator: IntValidator{bottom: 1000; top: 2000;}
 }

Usage for optional field:

 TextField {
     errorHighlight: text ? !acceptableInput : false
     //...
 }

font : Font

Font properties for the text.


inputMask : string

Sets an input mask on the TextField, restricting the allowable text inputs. See QLineEdit::inputMask for further details, as the exact same mask strings are used by TextField.


inputMethodHints : Qt::InputMethodHints

Sets the current input method hints.


placeholderText : string

Text that appear if there is no focus and no content on the component.


platformSipAttributes : Item

By default all attributes are disabled.

Sets the software input panel attributes.

This property should be set to an instance of SipAttributes, which can be used to e.g. highlight or disable the action key.


platformStyle : Item

Element holding the platform specific styling.


platformWesternNumericInputEnforced : bool

In some rare cases it is required to have a western numeric input panel even when the default input method is set to a language that uses non-western digits (like arabic). This may be the case when the input field expects, for example, credit card numbers.

The default is false.


readOnly : bool

Property default is false.

Whether the user can interact with the TextField item. If this property is set to true the user cannot edit the text.


selectedText : string

This read-only property provides the text currently selected in the text edit.


selectionEnd : int

The cursor position after the last character in the current selection.


selectionStart : int

The cursor position before the first character in the current selection.


text : string

The text to display. Does not contain the pre-edit text.


validator : QValidator

Sets a validator on the TextField. When a validator is set the TextField only accepts input which leaves the text property in an acceptable or intermediate state. The accepted signal is only sent if the text is in an acceptable state when enter is pressed. Currently supported validators are IntValidator, DoubleValidator and RegExpValidator.


Method Documentation

TextField::closeSoftwareInputPanel ()

Closes a software input panel like a virtual keyboard shown on the screen, useful for customizing when you want the input keyboard to be shown and hidden in your application.


TextField::copy ()

Copies the selected text into the clipboard.


TextField::cut ()

Cuts the selected text and copies it on the clipboard.


TextField::forceActiveFocus ()

Forces active focus on the item. This method sets the focus on the item and makes sure that all the focus scopes higher in the object hierarchy are also given focus.


TextField::openSoftwareInputPanel ()

Opens software input panels like virtual keyboards for typing, useful for customizing when you want the input keyboard to be shown and hidden in your application.


TextField::paste ()

Pastes the text from the clipboard in the current cursor position.


TextField::positionAt ( x, y )

Returns the text position closest to pixel position (x, y).

Position 0 is before the first character, position 1 is after the first character but before the second, and so on until position text.length, which is after all characters.


TextField::positionToRectangle ( pos )

Returns the rectangle at the given position pos in the text. The x, y, and height properties correspond to the cursor that would describe that position.


TextField::select ( start, end )

Selects the text between position start and end.


TextField::selectAll ()

Selects all the text.


TextField::selectWord ()

Selects the word nearest to the cursor position