IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

TextField QML Type

Displays a single line of editable plain text.

This type was introduced in Qt 5.1.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

TextField QML Type▲

  • Import Statement: import QtQuick.Controls 1.4

  • Since: Qt 5.1

  • Inherits: FocusScope

  • Group: TextField is part of https://

Detailed Description▲

Image non disponible

https:// is used to accept a line of text input. Input constraints can be placed on a https:// item (for example, through a https:// or https://). Setting https:// to an appropriate value enables https:// to be used for a password input field.

 
Sélectionnez
TextField {
    placeholderText: qsTr("Enter name")
}

You can create a custom appearance for a https:// by assigning a https://.

See Also▲

See also https://, https://

Property Documentation▲

 

[read-only] acceptableInput : bool▲

Returns true if the text field contains acceptable text.

If a validator or input mask was set, this property will return true if the current text satisfies the validator or mask as a final string (not as an intermediate string).

The default value is true.

See Also▲

See also https://, https://, https://

activeFocusOnPress : bool▲

This property is set to true if the https:// should gain active focus on a mouse press.

The default value is true.

[read-only] canPaste : bool▲

Returns true if the https:// is writable and the content of the clipboard is suitable for pasting into the https://.

[read-only] canRedo : bool▲

Returns true if the https:// is writable and there are https:// operations that can be redone.

[read-only] canUndo : bool▲

Returns true if the https:// is writable and there are previous operations that can be undone.

cursorPosition : int▲

This property holds the position of the cursor in the https://.

[read-only, since QtQuick.Controls 1.3] cursorRectangle : rect▲

The rectangle where the text cursor is rendered within the text field.

This property was introduced in QtQuick.Controls 1.3.

[read-only] displayText : string▲

This property holds the text displayed in the https://.

If https:// is set to TextInput::Normal, this holds the same value as the https:// property. Otherwise, this property holds the text visible to the user, while the https:// property holds the actual entered text.

echoMode : enumeration▲

Specifies how the text should be displayed in the https://.

The possible modes are:

  • https://.Normal - Displays the text as it is. (Default)

  • https://.Password - Displays asterisks instead of characters.

  • https://.NoEcho - Displays nothing.

  • https://.PasswordEchoOnEdit - Displays characters as they are entered while editing, otherwise displays asterisks.

[read-only] effectiveHorizontalAlignment : enumeration▲

Gets the effective horizontal alignment of the text within the https:// item's width.

https:// contains the default horizontal alignment.

See Also▲

See also https://

font : font▲

Sets the font of the https://.

horizontalAlignment : enumeration▲

Sets the alignment of the text within the https:// item's width.

By default, the horizontal text alignment follows the natural alignment of the text, for example text that is read from left to right will be aligned to the left.

The possible alignment values are:

  • https://.AlignLeft

  • https://.AlignRight

  • https://.AlignHCenter

When using the attached property, https://, to mirror application layouts, the horizontal alignment of text will also be mirrored. However, the property horizontalAlignment will remain unchanged. To query the effective horizontal alignment of https://, use the read-only property effectiveHorizontalAlignment.

[read-only] hovered : bool▲

This property holds whether the control is being hovered.

inputMask : string▲

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

See Also▲

See also https://, https://

[read-only, since QtQuick.Controls 1.3] inputMethodComposing : bool▲

This property holds whether the https:// has partial text input from an input method.

While it is composing an input method may rely on mouse or key events from the https:// 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.

This property was introduced in QtQuick.Controls 1.3.

inputMethodHints : enumeration▲

Provides hints to the input method about the expected content of the text field and how it should operate.

The value is a bit-wise combination of flags, or Qt.ImhNone if no hints are set.

The default value is Qt.ImhNone.

Flags that alter behavior are:

  • Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords. This is automatically set when setting https:// to TextInput.Password.

  • Qt.ImhSensitiveData - Typed text should not be stored by the active input method in any persistent storage like predictive user dictionary.

  • Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case when a sentence ends.

  • Qt.ImhPreferNumbers - Numbers are preferred (but not required).

  • Qt.ImhPreferUppercase - Uppercase letters are preferred (but not required).

  • Qt.ImhPreferLowercase - Lowercase letters are preferred (but not required).

  • Qt.ImhNoPredictiveText - Do not use predictive text (for example, dictionary lookup) while typing.

  • Qt.ImhDate - The text editor functions as a date field.

  • Qt.ImhTime - The text editor functions as a time field.

  • Qt.ImhMultiLine - The text editor doesn't close software input keyboard when Return or Enter key is pressed (since https://.Controls 1.3).

Flags that restrict input (exclusive flags) are:

  • Qt.ImhDigitsOnly - Only digits are allowed.

  • Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign.

  • Qt.ImhUppercaseOnly - Only uppercase letter input is allowed.

  • Qt.ImhLowercaseOnly - Only lowercase letter input is allowed.

  • Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed.

  • Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed.

  • Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed.

Masks:

  • Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used.

[read-only] length : int▲

Returns the total number of characters in the https:// item.

If the https:// has an input mask, the length will include mask characters and may differ from the length of the string returned by the https:// property.

This property can be faster than querying the length of the https:// property as it doesn't require any copying or conversion of the https://'s internal string data.

maximumLength : int▲

This property holds the maximum permitted length of the text in the https://.

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

[since QtQuick.Controls 1.3] menu : Component▲

This property was introduced in QtQuick.Controls 1.3.

placeholderText : string▲

This property contains the text that is shown in the text field when the text field is empty.

readOnly : bool▲

Sets whether user input can modify the contents of the https://. Read- only is different from a disabled text field in that the text field will appear to be active and text can still be selected and copied.

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

[since QtQuick.Controls 1.3] selectByMouse : bool▲

This property determines if the user can select the text with the mouse.

The default value is true.

This property was introduced in QtQuick.Controls 1.3.

[read-only] selectedText : string▲

Provides the text currently selected in the text input.

It is equivalent to the following snippet, but is faster and easier to use.

 
Sélectionnez
myTextField.text.toString().substring(myTextField.selectionStart, myTextField.selectionEnd);

[read-only] selectionEnd : int▲

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

This property is read-only. To change the selection, use select(start,end), https://(), or https://().

See Also▲

See also https://, https://, https://

[read-only] selectionStart : int▲

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

This property is read-only. To change the selection, use select(start,end), https://(), or https://().

See Also▲

See also https://, https://, https://

style : Component▲

The style Component for this control.

See Also▲

See also Qt Quick Controls Styles QML Types

text : string▲

This property contains the text in the https://.

textColor : color▲

This property holds the text color.

validator : Validator▲

Allows you to set a validator on the https://. When a validator is set, the https:// will only accept input which leaves the text property in an 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 https://, https://, and https://. An example of using validators is shown below, which allows input of integers between 11 and 31 into the text input:

 
Sélectionnez
import QtQuick 2.2
import QtQuick.Controls 1.2

TextField {
    validator: IntValidator {bottom: 11; top: 31;}
    focus: true
}
See Also▲

See also https://, https://, https://

verticalAlignment : enumeration▲

Sets the alignment of the text within the https:// item's height.

The possible alignment values are:

  • https://.AlignTop

  • https://.AlignBottom

  • https://.AlignVCenter (default).

Signal Documentation▲

 

accepted()▲

This signal is emitted when the Return or Enter key is pressed. Note that if there is a https:// or https:// set on the text field, the signal will only be emitted if the input is in an acceptable state.

The corresponding handler is onAccepted.

The corresponding handler is onAccepted.

[since QtQuick.Controls 1.1] editingFinished()▲

This signal is emitted when the Return or Enter key is pressed or the text field loses focus. Note that if there is a validator or https:// set on the text field and enter/return is pressed, this signal will only be emitted if the input follows the https:// and the validator returns an acceptable state.

The corresponding handler is onEditingFinished.

The corresponding handler is onEditingFinished.

This signal was introduced in QtQuick.Controls 1.1.

Method Documentation▲

 

void copy()▲

Copies the currently selected text to the system clipboard.

void cut()▲

Moves the currently selected text to the system clipboard.

void deselect()▲

Removes active text selection.

string getText(int start, int end)▲

Removes the section of text that is between the start and end positions from the https://.

void insert(int position, string text)▲

Inserts text into the https:// at position.

bool isRightToLeft(int start, int end)▲

Returns true if the natural reading direction of the editor text found between positions start and end is right to left.

void paste()▲

Replaces the currently selected text by the contents of the system clipboard.

void redo()▲

Performs the last operation if redo is https://.

[since QtQuick.Controls 1.4] void remove(int start, int end)▲

Removes the section of text that is between the start and end positions.

This method was introduced in QtQuick.Controls 1.4.

void select(int start, int end)▲

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 select, https:// will become the lesser and https:// will become the greater (regardless of the order passed to this method).

See Also▲

See also https://, https://

void selectAll()▲

Causes all text to be selected.

void selectWord()▲

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

void undo()▲

Reverts the last operation if undo is https://. undo() deselects any current selection and updates the selection start to the current cursor position.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.