Skip to content
This is the unreleased documentation for the next version of Slint.
For up-to-date documentation, see here.

LineEdit

import { LineEdit, VerticalBox } from "std-widgets.slint";
export component Example inherits Window {
width: 200px;
height: 60px;
VerticalBox {
LineEdit {
placeholder-text: "Enter text here";
}
}
}
slint
lineedit example

A widget used to enter a single line of text. See TextEdit for a widget able to handle several lines of text.

Properties

enabled

bool default: true

When false, nothing can be entered selecting text is still enabled as well as editing text programmatically.

font-size

length default: 0px

The size of the font of the input text

has-focus

bool (out) default: false

Set to true when the line edit currently has the focus

horizontal-alignment

enum TextHorizontalAlignment default: left

TextHorizontalAlignment

This enum describes the different types of alignment of text along the horizontal axis of a Text element.

  • left: The text will be aligned with the left edge of the containing box.
  • center: The text will be horizontally centered within the containing box.
  • right: The text will be aligned to the right of the containing box.

The horizontal alignment of the text.

input-type

enum InputType default: text

InputType

This enum is used to define the type of the input field.

  • text: The default value. This will render all characters normally
  • password: This will render all characters with a character that defaults to ”*”
  • number: This will only accept and render number characters (0-9)
  • decimal: This will accept and render characters if it’s valid part of a decimal

The way to allow special input viewing properties such as password fields.

LineEdit {
input-type: password;
}
slint

placeholder-text

string default: ""

A placeholder text being shown when there is no text in the edit field

read-only

bool default: false

When set to true, text editing via keyboard and mouse is disabled but selecting text is still enabled as well as editing text programmatically.

text

string (in-out) default: ""

The text being edited

LineEdit {
text: "Initial text";
}
slint

Functions

focus()

Call this function to focus the LineEdit and make it receive future keyboard events.

clear-focus()

Call this function to remove keyboard focus from this LineEdit if it currently has the focus. See also Focus Handling.

set-selection-offsets(int, int)

Selects the text between two UTF-8 offsets.

select-all()

Selects all text.

clear-selection()

Clears the selection.

copy()

Copies the selected text to the clipboard.

cut()

Copies the selected text to the clipboard and removes it from the editable area.

paste()

Pastes the text content of the clipboard at the cursor position.

Callbacks

accepted(string)

Invoked when the enter key is pressed.

LineEdit {
accepted(text) => {
debug("Accepted: ", text);
}
}
slint

rejected(string)

Invoked when the escape key is pressed.

LineEdit {
rejected(text) => {
debug("Rejected: ", text);
}
}
slint

edited(string)

Emitted when the text has changed because the user modified it

LineEdit {
edited(text) => {
debug("Text edited: ", text);
}
}
slint