• _images/inputbox.tpi.50d5caa785.png

    text input box with text “InputBox”

  • _images/inputbox-focus.tpi.5e3ba4520c.png

    in focused state

  • _images/inputbox-disabled.tpi.ee123f0354.png

    in disabled state

  • _images/inputbox-password.tpi.23b4da6394.png

    as password input

ZInputBox is a single line text input widget. If the input text is longer than the width of the widget it supports scrolling the text so the currently edited portion of the text is visible.


Tui::ZInputBox *inputbox = new Tui::ZInputBox("InputBox", dialog);

QObject::connect(inputbox, &Tui::ZInputBox::textChanged, [](const QString &text) { /* ... */ });

Keyboard Usage



(text input)

Insert text at cursor position.


Remove one letter/character before cursor position.


Remove one letter/character after cursor position.

Move cursor position one letter/character to the left.

Move cursor position one letter/character to the right.


Move cursor position to the start of the text.


Move cursor position to the position just after the end of the text.


Toggle overwrite mode.


Input boxes by default accept focus, are one cell high and have a expanding vertical layout policy. The size request of a checkbox is fixed at 10 cells width to avoid the layout changing when text is entered.

The user can edit the text by using the keys described in the keyboard usage section. Additionally the input box accepts text pasted into the terminal and inserts it at the cursor position. On each change to the text the input box emits a textChanged(const QString &text) signal.

When unfocused the text is always scrolled such that the start of the text is visible. When focused the text is scrolled so that the cursor position is visible.

Newline (\n) characters in the text are displayed as in the following example (displaying one\ntwo):


Other non printable characters are displayed using similar visual conventions.


Palette Color


lineedit.fg, lineedit.bg

Body of the input box (active, unfocused)

lineedit.focused.fg, lineedit.focused.bg

Body of the input box (active, focused)

lineedit.disabled.fg, lineedit.disabled.bg

Body of the input box (disabled)


class Tui::ZInputBox : public Tui::ZWidget

A single line text input widget.


enum EchoMode
enumerator Normal

Display text normally

enumerator NoEcho

Do not display any text and show cursor at start of the widget. This is the classic everything hidden password input.

enumerator Password

Display text masked by *. This is the modern masked password input that leaks passwort length but provides better feedback and editing.


ZInputBox(const QString &text, Tui::ZWidget *parent = nullptr)

Create the input box with the given text.


QString text() const

Get the text from the input box.

void setEchoMode(Tui::ZInputBox::EchoMode echoMode)
Tui::ZInputBox::EchoMode echoMode() const

The echoMode allows selecting how the input text is displayed. This allows selecting normal display or password input modes.

void setOverwriteMode(bool overwriteMode)
bool overwriteMode() const

The overwriteMode allows for user input to overwrite existing text.

If true user input letters will overwrite the existing letter the cursor is placed on. Otherwise it will be inserted after the cursor.

int cursorPosition() const
void setCursorPosition(int pos)

The cursor position in code units.

If the cursor position is out of range it will be adjusted to be in the range from 0 to the length of the current text (in code units). The cursor position is conceptually between letters/characters (clusters).

If the given cursor position is not at the start of a cluster (or at the end of the text) in text, it will be adjusted to the preceding valid cursor position.

void insertAtCursorPosition(const QString &text)

Insert the text given in text at the current cursor position and emits textChanged(const QString &text).


void textChanged(const QString &text)

This signal is emitted when the user changes the text or the text is changed using functions on this widget.


void setText(const QString &text)

If text differs from the current text: Replace the text with text and emits textChanged(const QString &text). Sets cursor position to the end of the text.