75void QLineEdit::initStyleOption(QStyleOptionFrame *option)
const
81 option->initFrom(
this);
82 option->rect = contentsRect();
83 option->lineWidth = d->frame ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option,
this)
85 option->midLineWidth = 0;
86 option->state |= QStyle::State_Sunken;
87 if (d->control->isReadOnly())
88 option->state |= QStyle::State_ReadOnly;
89#ifdef QT_KEYPAD_NAVIGATION
91 option->state |= QStyle::State_HasEditFocus;
93 option->features = QStyleOptionFrame::None;
459void QLineEdit::setClearButtonEnabled(
bool enable)
463 if (enable == isClearButtonEnabled())
466 QAction *clearAction =
new QAction(d->clearButtonIcon(), QString(),
this);
467 clearAction->setEnabled(!isReadOnly());
468 clearAction->setObjectName(QLatin1StringView(clearButtonActionNameC));
470 int flags = QLineEditPrivate::SideWidgetClearButton | QLineEditPrivate::SideWidgetFadeInWithText;
471 auto widgetAction = d->addAction(clearAction,
nullptr, QLineEdit::TrailingPosition, flags);
472 widgetAction->setVisible(!text().isEmpty());
474 QAction *clearAction = findChild<QAction *>(QLatin1StringView(clearButtonActionNameC));
475 Q_ASSERT(clearAction);
476 d->removeAction(clearAction);
548void QLineEdit::setEchoMode(EchoMode mode)
551 if (mode == (EchoMode)d->control->echoMode())
553 Qt::InputMethodHints imHints = inputMethodHints();
554 imHints.setFlag(Qt::ImhHiddenText, mode == Password || mode == NoEcho);
555 imHints.setFlag(Qt::ImhNoAutoUppercase, mode != Normal);
556 imHints.setFlag(Qt::ImhNoPredictiveText, mode != Normal);
557 imHints.setFlag(Qt::ImhSensitiveData, mode != Normal);
558 setInputMethodHints(imHints);
559 d->control->setEchoMode(mode);
661QSize QLineEdit::sizeHint()
const
663 Q_D(
const QLineEdit);
665 QFontMetrics fm(font());
666 const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize,
nullptr,
this);
667 const QMargins tm = d->effectiveTextMargins();
668 int h = qMax(fm.height(), qMax(14, iconSize - 2)) + 2 * QLineEditPrivate::verticalMargin
669 + tm.top() + tm.bottom()
670 + d->topmargin + d->bottommargin;
671 int w = fm.horizontalAdvance(u'x') * 17 + 2 * QLineEditPrivate::horizontalMargin
672 + tm.left() + tm.right()
673 + d->leftmargin + d->rightmargin;
674 QStyleOptionFrame opt;
675 initStyleOption(&opt);
676 return style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h),
this);
686QSize QLineEdit::minimumSizeHint()
const
688 Q_D(
const QLineEdit);
690 QFontMetrics fm = fontMetrics();
691 const QMargins tm = d->effectiveTextMargins();
692 int h = fm.height() + qMax(2 * QLineEditPrivate::verticalMargin, fm.leading())
693 + tm.top() + tm.bottom()
694 + d->topmargin + d->bottommargin;
695 int w = fm.maxWidth() + 2 * QLineEditPrivate::horizontalMargin
696 + tm.left() + tm.right()
697 + d->leftmargin + d->rightmargin;
698 QStyleOptionFrame opt;
699 initStyleOption(&opt);
700 return style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h),
this);
1344void QLineEdit::setReadOnly(
bool enable)
1347 if (d->control->isReadOnly() != enable) {
1348 d->control->setReadOnly(enable);
1349 d->setClearButtonEnabled(!enable);
1350 setAttribute(Qt::WA_MacShowFocusRect, !enable);
1351 setAttribute(Qt::WA_InputMethodEnabled, d->shouldEnableInputMethod());
1353 setCursor(enable ? Qt::ArrowCursor : Qt::IBeamCursor);
1355 QEvent event(QEvent::ReadOnlyChange);
1356 QCoreApplication::sendEvent(
this, &event);
1358#if QT_CONFIG(accessibility)
1359 QAccessible::State changedState;
1360 changedState.readOnly =
true;
1361 QAccessibleStateChangeEvent ev(
this, changedState);
1362 QAccessible::updateAccessibility(&ev);
1438bool QLineEdit::event(QEvent * e)
1441 if (e->type() == QEvent::ContextMenu) {
1443 if (d->control->composeMode())
1447 }
else if (e->type() == QEvent::WindowActivate) {
1448 QTimer::singleShot(0,
this, [
this]() {
1450 d->handleWindowActivate();
1452#ifndef QT_NO_SHORTCUT
1453 }
else if (e->type() == QEvent::ShortcutOverride) {
1454 QKeyEvent *ke =
static_cast<QKeyEvent*>(e);
1455 d->control->processShortcutOverrideEvent(ke);
1457 }
else if (e->type() == QEvent::Show) {
1460 d->control->setBlinkingCursorEnabled(
true);
1461 QStyleOptionFrame opt;
1462 initStyleOption(&opt);
1463 if ((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
1464 || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt,
this))
1465 d->setCursorVisible(
true);
1467 }
else if (e->type() == QEvent::Hide) {
1468 d->control->setBlinkingCursorEnabled(
false);
1469#if QT_CONFIG(action)
1470 }
else if (e->type() == QEvent::ActionRemoved) {
1471 d->removeAction(
static_cast<QActionEvent *>(e)->action());
1473 }
else if (e->type() == QEvent::Resize) {
1474 d->positionSideWidgets();
1475 }
else if (e->type() == QEvent::StyleChange) {
1476 d->initMouseYThreshold();
1478#ifdef QT_KEYPAD_NAVIGATION
1479 if (QApplicationPrivate::keypadNavigationEnabled()) {
1480 if (e->type() == QEvent::EnterEditFocus) {
1482 d->setCursorVisible(
true);
1483 d->control->setCursorBlinkEnabled(
true);
1484 }
else if (e->type() == QEvent::LeaveEditFocus) {
1485 d->setCursorVisible(
false);
1486 d->control->setCursorBlinkEnabled(
false);
1487 if (d->edited && (d->control->hasAcceptableInput()
1488 || d->control->fixup())) {
1489 emit editingFinished();
1495 return QWidget::event(e);
1500void QLineEdit::mousePressEvent(QMouseEvent* e)
1504 d->mousePressPos = e->position().toPoint();
1506 if (d->sendMouseEventToInputContext(e))
1508 if (e->button() == Qt::RightButton) {
1512#ifdef QT_KEYPAD_NAVIGATION
1513 if (QApplication::QApplicationPrivate() && !hasEditFocus()) {
1516 if (d->control->completer())
1517 d->control->completer()->complete();
1520 if (d->tripleClickTimer.isActive() && (e->position().toPoint() - d->tripleClick).manhattanLength() <
1521 QApplication::startDragDistance()) {
1525 bool mark = e->modifiers() & Qt::ShiftModifier;
1527 mark = mark && (d->imHints & Qt::ImhNoPredictiveText);
1529 int cursor = d->xToPos(e->position().toPoint().x());
1530#if QT_CONFIG(draganddrop)
1531 if (!mark && d->dragEnabled && d->control->echoMode() == Normal &&
1532 e->button() == Qt::LeftButton && d->inSelection(e->position().toPoint().x())) {
1533 if (!d->dndTimer.isActive())
1534 d->dndTimer.start(QApplication::startDragTime(),
this);
1538 d->control->moveCursor(cursor, mark);
1544void QLineEdit::mouseMoveEvent(QMouseEvent * e)
1548 if (e->buttons() & Qt::LeftButton) {
1549#if QT_CONFIG(draganddrop)
1550 if (d->dndTimer.isActive()) {
1551 if ((d->mousePressPos - e->position().toPoint()).manhattanLength() > QApplication::startDragDistance())
1557 const bool select =
true;
1559 const bool select = (d->imHints & Qt::ImhNoPredictiveText);
1562 if (d->mouseYThreshold > 0 && e->position().toPoint().y() > d->mousePressPos.y() + d->mouseYThreshold) {
1563 if (layoutDirection() == Qt::RightToLeft)
1564 d->control->home(select);
1566 d->control->end(select);
1567 }
else if (d->mouseYThreshold > 0 && e->position().toPoint().y() + d->mouseYThreshold < d->mousePressPos.y()) {
1568 if (layoutDirection() == Qt::RightToLeft)
1569 d->control->end(select);
1571 d->control->home(select);
1572 }
else if (d->control->composeMode() && select) {
1573 int startPos = d->xToPos(d->mousePressPos.x());
1574 int currentPos = d->xToPos(e->position().toPoint().x());
1575 if (startPos != currentPos)
1576 d->control->setSelection(startPos, currentPos - startPos);
1581 d->control->moveCursor(d->xToPos(e->position().toPoint().x()), select);
1586 d->sendMouseEventToInputContext(e);
1591void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
1594 if (d->sendMouseEventToInputContext(e))
1596#if QT_CONFIG(draganddrop)
1597 if (e->button() == Qt::LeftButton) {
1598 if (d->dndTimer.isActive()) {
1605#ifndef QT_NO_CLIPBOARD
1606 if (QGuiApplication::clipboard()->supportsSelection()) {
1607 if (e->button() == Qt::LeftButton) {
1608 d->control->copy(QClipboard::Selection);
1609 }
else if (!d->control->isReadOnly() && e->button() == Qt::MiddleButton) {
1611 d->control->paste(QClipboard::Selection);
1616 if (!isReadOnly() && rect().contains(e->position().toPoint()))
1617 d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
1618 d->clickCausedFocus = 0;
1623void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e)
1627 if (e->button() == Qt::LeftButton) {
1628 int position = d->xToPos(e->position().toPoint().x());
1632 if (d->control->composeMode()) {
1633 int preeditPos = d->control->cursor();
1634 int posInPreedit = position - d->control->cursor();
1635 int preeditLength = d->control->preeditAreaText().size();
1636 bool positionOnPreedit =
false;
1638 if (posInPreedit >= 0 && posInPreedit <= preeditLength)
1639 positionOnPreedit =
true;
1641 int textLength = d->control->end();
1642 d->control->commitPreedit();
1643 int sizeChange = d->control->end() - textLength;
1645 if (positionOnPreedit) {
1646 if (sizeChange == 0)
1650 position = qBound(preeditPos, position, preeditPos + sizeChange);
1651 }
else if (position > preeditPos) {
1653 position += (sizeChange - preeditLength);
1659 d->control->selectWordAtPos(position);
1661 d->tripleClickTimer.start(QApplication::doubleClickInterval(),
this);
1662 d->tripleClick = e->position().toPoint();
1664 d->sendMouseEventToInputContext(e);
1717void QLineEdit::keyPressEvent(QKeyEvent *event)
1720 #ifdef QT_KEYPAD_NAVIGATION
1721 bool select =
false;
1722 switch (event->key()) {
1723 case Qt::Key_Select:
1724 if (QApplicationPrivate::keypadNavigationEnabled()) {
1725 if (hasEditFocus()) {
1726 setEditFocus(
false);
1727 if (d->control->completer() && d->control->completer()->popup()->isVisible())
1728 d->control->completer()->popup()->hide();
1735 if (!QApplicationPrivate::keypadNavigationEnabled() || !hasEditFocus()) {
1741 if (QApplicationPrivate::keypadNavigationEnabled()) {
1742 if (!hasEditFocus() && !(event->modifiers() & Qt::ControlModifier)) {
1743 if (!event->text().isEmpty() && event->text().at(0).isPrint()
1756 if (QApplicationPrivate::keypadNavigationEnabled() && !select && !hasEditFocus()) {
1758 if (event->key() == Qt::Key_Select)
1762 d->control->processKeyEvent(event);
1763 if (event->isAccepted())
1764 d->control->updateCursorBlinking();
1847QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument)
const
1849 Q_D(
const QLineEdit);
1852 return isEnabled() && !isReadOnly();
1853 case Qt::ImCursorRectangle:
1854 return d->cursorRect();
1855 case Qt::ImAnchorRectangle:
1856 return d->adjustedControlRect(d->control->anchorRect());
1859 case Qt::ImAbsolutePosition:
1860 case Qt::ImCursorPosition: {
1861 const QPointF pt = argument.toPointF();
1863 return QVariant(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters));
1864 return QVariant(d->control->cursor()); }
1865 case Qt::ImSurroundingText:
1866 return QVariant(d->control->surroundingText());
1867 case Qt::ImCurrentSelection:
1868 return QVariant(selectedText());
1869 case Qt::ImMaximumTextLength:
1870 return QVariant(maxLength());
1871 case Qt::ImAnchorPosition:
1872 if (d->control->selectionStart() == d->control->selectionEnd())
1873 return QVariant(d->control->cursor());
1874 else if (d->control->selectionStart() == d->control->cursor())
1875 return QVariant(d->control->selectionEnd());
1877 return QVariant(d->control->selectionStart());
1878 case Qt::ImReadOnly:
1879 return isReadOnly();
1880 case Qt::ImTextBeforeCursor: {
1881 const QPointF pt = argument.toPointF();
1883 return d->textBeforeCursor(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters));
1885 return d->textBeforeCursor(d->control->cursor()); }
1886 case Qt::ImTextAfterCursor: {
1887 const QPointF pt = argument.toPointF();
1889 return d->textAfterCursor(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters));
1891 return d->textAfterCursor(d->control->cursor()); }
1893 return QWidget::inputMethodQuery(property);
1900void QLineEdit::focusInEvent(QFocusEvent *e)
1903 if (e->reason() == Qt::TabFocusReason ||
1904 e->reason() == Qt::BacktabFocusReason ||
1905 e->reason() == Qt::ShortcutFocusReason) {
1906 if (!d->control->inputMask().isEmpty())
1907 d->control->moveCursor(d->control->nextMaskBlank(0));
1908 else if (!d->control->hasSelectedText())
1912 }
else if (e->reason() == Qt::MouseFocusReason) {
1913 d->clickCausedFocus = 1;
1916#ifdef QT_KEYPAD_NAVIGATION
1917 if (!QApplicationPrivate::keypadNavigationEnabled() || (hasEditFocus() && ( e->reason() == Qt::PopupFocusReason))) {
1919 d->control->setBlinkingCursorEnabled(
true);
1920 QStyleOptionFrame opt;
1921 initStyleOption(&opt);
1922 if ((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
1923 || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt,
this))
1924 d->setCursorVisible(
true);
1925#ifdef QT_KEYPAD_NAVIGATION
1926 d->control->setCancelText(d->control->text());
1929#if QT_CONFIG(completer)
1930 if (d->control->completer()) {
1931 d->control->completer()->setWidget(
this);
1932 d->connectCompleter();
1940void QLineEdit::focusOutEvent(QFocusEvent *e)
1943 if (d->control->passwordEchoEditing()) {
1946 d->updatePasswordEchoEditing(
false);
1949 Qt::FocusReason reason = e->reason();
1950 if (reason != Qt::ActiveWindowFocusReason &&
1951 reason != Qt::PopupFocusReason)
1954 d->setCursorVisible(
false);
1955 d->control->setBlinkingCursorEnabled(
false);
1956#ifdef QT_KEYPAD_NAVIGATION
1958 if (!QApplicationPrivate::keypadNavigationEnabled())
1960 if (reason != Qt::PopupFocusReason
1961 || !(QApplication::activePopupWidget() && QApplication::activePopupWidget()->parentWidget() ==
this)) {
1962 if (d->edited && (hasAcceptableInput() || d->control->fixup())) {
1963 emit editingFinished();
1967#ifdef QT_KEYPAD_NAVIGATION
1968 d->control->setCancelText(QString());
1970#if QT_CONFIG(completer)
1971 if (d->control->completer())
1972 d->disconnectCompleter();
1974 QWidget::focusOutEvent(e);
1979void QLineEdit::paintEvent(QPaintEvent *)
1983 QPalette pal = palette();
1985 QStyleOptionFrame panel;
1986 initStyleOption(&panel);
1987 style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p,
this);
1988 QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &panel,
this);
1989 r = r.marginsRemoved(d->effectiveTextMargins());
1992 QFontMetrics fm = fontMetrics();
1994 if (d->shouldShowPlaceholderText())
1995 fmHeight = fm.boundingRect(d->placeholderText).height();
1997 fmHeight = fm.boundingRect(d->control->text() + d->control->preeditAreaText()).height();
1998 fmHeight = qMax(fmHeight, fm.height());
2000 Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment));
2001 switch (va & Qt::AlignVertical_Mask) {
2002 case Qt::AlignBottom:
2003 d->vscroll = r.y() + r.height() - fmHeight - QLineEditPrivate::verticalMargin;
2006 d->vscroll = r.y() + QLineEditPrivate::verticalMargin;
2010 d->vscroll = r.y() + (r.height() - fmHeight + 1) / 2;
2013 QRect lineRect(r.x() + QLineEditPrivate::horizontalMargin, d->vscroll,
2014 r.width() - 2 * QLineEditPrivate::horizontalMargin, fmHeight);
2016 if (d->shouldShowPlaceholderText()) {
2017 if (!d->placeholderText.isEmpty()) {
2018 const Qt::LayoutDirection layoutDir = d->placeholderText.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
2019 const Qt::Alignment alignPhText = QStyle::visualAlignment(layoutDir, QFlag(d->alignment));
2020 const QColor col = pal.placeholderText().color();
2021 QPen oldpen = p.pen();
2023 Qt::LayoutDirection oldLayoutDir = p.layoutDirection();
2024 p.setLayoutDirection(layoutDir);
2026 const QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width());
2027 p.drawText(lineRect, alignPhText, elidedText);
2029 p.setLayoutDirection(oldLayoutDir);
2033 int cix = qRound(d->control->cursorToX());
2040 int widthUsed = qRound(d->control->naturalTextWidth()) + 1;
2041 if (widthUsed <= lineRect.width()) {
2043 switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
2044 case Qt::AlignRight:
2045 d->hscroll = widthUsed - lineRect.width() + 1;
2047 case Qt::AlignHCenter:
2048 d->hscroll = (widthUsed - lineRect.width()) / 2;
2055 }
else if (cix - d->hscroll >= lineRect.width()) {
2057 d->hscroll = cix - lineRect.width() + 1;
2058 }
else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) {
2061 }
else if (widthUsed - d->hscroll < lineRect.width()) {
2064 d->hscroll = widthUsed - lineRect.width() + 1;
2067 d->hscroll = qMax(0, d->hscroll);
2072 QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
2075#if QT_CONFIG(style_stylesheet)
2076 if (QStyleSheetStyle* cssStyle = qt_styleSheet(style())) {
2077 cssStyle->styleSheetPalette(
this, &panel, &pal);
2080 p.setPen(pal.text().color());
2082 int flags = QWidgetLineControl::DrawText;
2084#ifdef QT_KEYPAD_NAVIGATION
2085 if (!QApplicationPrivate::keypadNavigationEnabled() || hasEditFocus())
2087 if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){
2088 flags |= QWidgetLineControl::DrawSelections;
2090 if (d->control->palette() != pal
2091 || d->control->palette().currentColorGroup() != pal.currentColorGroup())
2092 d->control->setPalette(pal);
2100 if (d->cursorVisible && !d->control->isReadOnly() && d->control->inputMask().isEmpty())
2101 flags |= QWidgetLineControl::DrawCursor;
2103 d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth, &panel,
this));
2104 d->control->draw(&p, topLeft, r, flags);
2208QMenu *QLineEdit::createStandardContextMenu()
2211 QMenu *popup =
new QMenu(
this);
2212 popup->setObjectName(
"qt_edit_menu"_L1);
2213 QAction *action =
nullptr;
2215 if (!isReadOnly()) {
2216 action = popup->addAction(QLineEdit::tr(
"&Undo") +
ACCEL_KEY(QKeySequence::Undo));
2217 action->setEnabled(d->control->isUndoAvailable());
2218 action->setObjectName(QStringLiteral(
"edit-undo"));
2219 setActionIcon(action, QStringLiteral(
"edit-undo"));
2220 connect(action, &QAction::triggered,
this, &QLineEdit::undo);
2222 action = popup->addAction(QLineEdit::tr(
"&Redo") +
ACCEL_KEY(QKeySequence::Redo));
2223 action->setEnabled(d->control->isRedoAvailable());
2224 action->setObjectName(QStringLiteral(
"edit-redo"));
2225 setActionIcon(action, QStringLiteral(
"edit-redo"));
2226 connect(action, &QAction::triggered,
this, &QLineEdit::redo);
2228 popup->addSeparator();
2231#ifndef QT_NO_CLIPBOARD
2232 if (!isReadOnly()) {
2233 action = popup->addAction(QLineEdit::tr(
"Cu&t") +
ACCEL_KEY(QKeySequence::Cut));
2234 action->setEnabled(!d->control->isReadOnly() && d->control->hasSelectedText()
2235 && d->control->echoMode() == QLineEdit::Normal);
2236 action->setObjectName(QStringLiteral(
"edit-cut"));
2237 setActionIcon(action, QStringLiteral(
"edit-cut"));
2238 connect(action, &QAction::triggered,
this, &QLineEdit::cut);
2241 action = popup->addAction(QLineEdit::tr(
"&Copy") +
ACCEL_KEY(QKeySequence::Copy));
2242 action->setEnabled(d->control->hasSelectedText()
2243 && d->control->echoMode() == QLineEdit::Normal);
2244 action->setObjectName(QStringLiteral(
"edit-copy"));
2245 setActionIcon(action, QStringLiteral(
"edit-copy"));
2246 connect(action, &QAction::triggered,
this, &QLineEdit::copy);
2248 if (!isReadOnly()) {
2249 action = popup->addAction(QLineEdit::tr(
"&Paste") +
ACCEL_KEY(QKeySequence::Paste));
2250 action->setEnabled(!d->control->isReadOnly() && !QGuiApplication::clipboard()->text().isEmpty());
2251 action->setObjectName(QStringLiteral(
"edit-paste"));
2252 setActionIcon(action, QStringLiteral(
"edit-paste"));
2253 connect(action, &QAction::triggered,
this, &QLineEdit::paste);
2257 if (!isReadOnly()) {
2258 action = popup->addAction(QLineEdit::tr(
"Delete"));
2259 action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText());
2260 action->setObjectName(QStringLiteral(
"edit-delete"));
2261 setActionIcon(action, QStringLiteral(
"edit-delete"));
2262 connect(action, &QAction::triggered,
2263 d->control, &QWidgetLineControl::_q_deleteSelected);
2266 if (!popup->isEmpty())
2267 popup->addSeparator();
2269 action = popup->addAction(QLineEdit::tr(
"Select All") +
ACCEL_KEY(QKeySequence::SelectAll));
2270 action->setEnabled(!d->control->text().isEmpty() && !d->control->allSelected());
2271 action->setObjectName(QStringLiteral(
"select-all"));
2272 setActionIcon(action, QStringLiteral(
"edit-select-all"));
2273 d->selectAllAction = action;
2274 connect(action, &QAction::triggered,
this, &QLineEdit::selectAll);
2276 if (!d->control->isReadOnly() && QGuiApplication::styleHints()->useRtlExtensions()) {
2277 popup->addSeparator();
2278 QUnicodeControlCharacterMenu *ctrlCharacterMenu =
new QUnicodeControlCharacterMenu(
this, popup);
2279 popup->addMenu(ctrlCharacterMenu);
2286void QLineEdit::changeEvent(QEvent *ev)
2291 case QEvent::ActivationChange:
2292 if (!palette().isEqual(QPalette::Active, QPalette::Inactive))
2295 case QEvent::FontChange:
2296 d->control->setFont(font());
2298 case QEvent::StyleChange:
2300 QStyleOptionFrame opt;
2301 initStyleOption(&opt);
2302 d->control->setPasswordCharacter(
char16_t(style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt,
this)));
2303 d->control->setPasswordMaskDelay(style()->styleHint(QStyle::SH_LineEdit_PasswordMaskDelay, &opt,
this));
2307 case QEvent::LayoutDirectionChange:
2308#if QT_CONFIG(toolbutton)
2309 for (
const auto &e : d->trailingSideWidgets) {
2310 if (e.flags & QLineEditPrivate::SideWidgetClearButton)
2311 static_cast<QLineEditIconButton *>(e.widget)->setIcon(d->clearButtonIcon());
2314 d->positionSideWidgets();
2319 QWidget::changeEvent(ev);