Technology Sharing

Commonly used controls (III)

2024-07-11

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

QLineEdit

QLineEdit is used to represent a single-line input box, where you can enter a paragraph of text but cannot wrap.

Core Attributes:

Attributesillustrate
textText in the input box
inputMaskInput content format constraints
maxLengthThe maximum length
frameWhether to add a border
echoModeDisplay mode: 1. QLineEdit::Normal: This is the default value, the text box will display the entered text. 2. QLineEdit::Password: In this mode, the entered characters will be hidden, usually replaced by (*) or (=) 3. QLineEdit::NoEcho: In this mode, the text box will not echo any entered characters
cursorPositionCursor location
alignmentText alignment, set horizontal and vertical alignment
dragEnabledIs dragging allowed?
readOnlyIs it read-only (modification is not allowed)
placeHolderTextWhen the input box is empty, what kind of prompt message is displayed
clearButtonEnabledWhether the "clear button" will be automatically displayed

Core signal:

Signalillustrate
void cursorPositionChanged(int old, int new)When the mouse moves, a signal is emitted, old is the previous position, and new is the new position
void editingFinished()This signal is emitted when the Back or Enter key is pressed, or when the line edit loses focus.
void returnPressed()This signal is triggered when the return or enter key is pressed. If a validator is set, it must pass the validation to be triggered.
void selectionChanged()This signal is emitted when the selected text changes.
void textChanged(const QString