Contents

TextField

The TextField element displays a single line of editable plain text. Input constraints can be set through validator or inputMask. Setting echoMode to an appropriate value enables TextField to be used as password input field. More...

Properties

Signals

Signal Handlers

Methods

Detailed Description

This component is under heavy development.

Example:

Item {
    TextField {
        placeholderText: "hint text"
    }

    TextField {
        placeholderText: "without clear sign"
        hasClearButton: false
    }

    TextField {
        placeholderText: "password"
        echoMode: TextInput.Password
    }

    TextField {
        placeholderText: "overlaid in front"
        primaryItem: Image {
            height: parent.height
            width: height
            source: "magnifier.png"
        }
        secondaryItem: Row {
            Button {
                ItemStyle.class: "transparent-button"
                height: parent.height
                width: height
                iconSource: "caps-lock.png"
                onClicked: doSomething()
            }
            Button {
                ItemStyle.class: "transparent-button"
                height: parent.height
                width: height
                iconSource: "num-lock.png"
                onClicked: doSomething()
            }
        }
    }
}

Property Documentation

acceptableInput : alias

This documentation is under development and is subject to change.

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 : alias

This documentation is under development and is subject to change.

The position of the cursor in the TextField.


customSoftwareInputPanel : Component

This documentation is under development and is subject to change.

Component to be shown and used instead of the default On Screen Keyboard.


echoMode : alias

This documentation is under development and is subject to change.

Specifies how the text should be displayed in the TextField.

- TextInput.Normal - Displays the text as it is. (Default) - TextInput.Password - Displays asterixes instead of characters. - TextInput.NoEcho - Displays nothing. - TextInput.PasswordEchoOnEdit - Displays characters as they are entered while editing, otherwise displays asterisks.


errorHighlight : bool

This documentation is under development and is subject to change.

Allows highlighting errors in the TextField.


font : alias

This documentation is under development and is subject to change.

Font used in the TextField.


hasClearButton : bool

This documentation is under development and is subject to change.

Specifies whether the control has a clear button or not.


highlighted : bool

The property presents whether the TextField is highlighted or not. By default the TextField gets highlighted when gets the focus, so can accept text input. This property allows to control the highlight separately from the focused behavior.


inputMask : alias

This documentation is under development and is subject to change.

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


inputMethodComposing : alias

This documentation is under development and is subject to change.

This property holds whether the TextInput has partial text input from an input method.

While it is composing an input method may rely on mouse or key events from the TextField to edit or commit the partial text. This property can be used to determine when to disable events handlers that may interfere with the correct operation of an input method.


maximumLength : alias

This documentation is under development and is subject to change.

The maximum permitted length of the text in the TextField.

If the text is too long, it is truncated at the limit.

By default, this property contains a value of 32767.


placeholderText : alias

This documentation is under development and is subject to change.

Text that appears when there is no focus and no content in the component.


popover : var

The property overrides the default popover of the TextField. When set, the TextField will open the given popover instead of the defaul tone defined. The popover can either be a component or a URL to be loaded.


primaryItem : alias

This documentation is under development and is subject to change.

Overlaid component that can be set for the fore side of the TextField, e.g.showing a magnifier to implement search functionality.


readOnly : alias

This documentation is under development and is subject to change.

Sets whether user input can modify the contents of the TextField.

If readOnly is set to true, then user input will not affect the text property. Any bindings or attempts to set the text property will still work.


secondaryItem : alias

This documentation is under development and is subject to change.

Overlaid component that can be set for the rear side of the TextField, e.g.showing a CAPS LOCK or NUM LOCK indication. The overlaid components will be placed right after the clear button.


selectedText : alias

This documentation is under development and is subject to change.

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


selectionEnd : alias

This documentation is under development and is subject to change.

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

This property is read-only. To change the selection, use select(start,end), selectAll(), or selectWord().


selectionStart : alias

This documentation is under development and is subject to change.

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

This property is read-only. To change the selection, use select(start,end), selectAll(), or selectWord().


text : alias

This documentation is under development and is subject to change.

The text in the TextField.


validator : alias

This documentation is under development and is subject to change.

Allows you to set a validator on the TextInput. When a validator is set the TextField will only accept input which leaves the text property in an acceptable or intermediate state. The accepted signal will only be sent if the text is in an acceptable state when enter is pressed.

Currently supported validators are IntValidator, DoubleValidator and RegExpValidator. An example of using validators is shown below, which allows input of integers between 11 and 31 into the text input:

import QtQuick 2.0
TextInput{
    validator: IntValidator{bottom: 11; top: 31;}
    focus: true
}

Signal Documentation

TextField::accepted()

This documentation is under development and is subject to change.

This handler is called when the Return or Enter key is pressed. Note that if there is a validator or inputMask set on the text input, the handler will only be emitted if the input is in an acceptable state.


Signal Handler Documentation

TextField::onVisibleChanged()

internal


Method Documentation

TextField::copy()

This documentation is under development and is subject to change.

Copies the currently selected text to the system clipboard.


TextField::cut()

This documentation is under development and is subject to change.

Moves the currently selected text to the system clipboard.


TextField::deselect()

This documentation is under development and is subject to change.

Removes active text selection.


TextField::paste( data)

This documentation is under development and is subject to change.

Places the clipboard or the data given as parameter into the text input. The selected text will be replaces with the data.


TextField::positionAt( x, position)

This documentation is under development and is subject to change.

This function returns the character position at x pixels from the left of the TextField. 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.

This means that for all x values before the first character this function returns 0, and for all x values after the last character this function returns text.length.

The cursor position type specifies how the cursor position should be resolved.

- TextInput.CursorBetweenCharacters - Returns the position between characters that is nearest x. - TextInput.CursorOnCharacter - Returns the position before the character that is nearest x.


TextField::positionToRectangle( pos)

This documentation is under development and is subject to change.

This function takes a character position and returns the rectangle that the cursor would occupy, if it was placed at that character position.

This is similar to setting the cursorPosition, and then querying the cursor rectangle, but the cursorPosition is not changed.


TextField::select( start, end)

This documentation is under development and is subject to change.

Causes the text from start to end to be selected.

If either start or end is out of range, the selection is not changed.

After calling this, selectionStart will become the lesser and selectionEnd will become the greater (regardless of the order passed to this method).


TextField::selectAll()

This documentation is under development and is subject to change.

Causes all text to be selected.


TextField::selectWord()

This documentation is under development and is subject to change.

Causes the word closest to the current cursor position to be selected.