8#if QT_CONFIG(itemviews)
11#if QT_CONFIG(draganddrop)
18#if QT_CONFIG(accessibility)
26#if QT_CONFIG(animation)
76#if QT_CONFIG(completer)
77void QLineEditPrivate::connectCompleter()
83 this, &QLineEditPrivate::completionHighlighted);
86void QLineEditPrivate::disconnectCompleter()
92 this, &QLineEditPrivate::completionHighlighted);
95void QLineEditPrivate::completionHighlighted(
const QString &newText)
106 const bool mark =
true;
128#if QT_CONFIG(completer)
139 emit q->cursorPositionChanged(from, to);
142#ifdef QT_KEYPAD_NAVIGATION
143void QLineEditPrivate::editFocusChange(
bool e)
155 q->initStyleOption(&
opt);
162 emit q->selectionChanged();
163#if QT_CONFIG(accessibility)
166 QAccessible::updateAccessibility(&ev);
179 const auto qUpdateMicroFocus = [
q]()
181 q->updateMicroFocus();
196#ifdef QT_KEYPAD_NAVIGATION
198 this, &QLineEditPrivate::editFocusChange);
201 q, qUpdateMicroFocus);
204 q, qUpdateMicroFocus);
207 q, qUpdateMicroFocus);
214 q, qUpdateMicroFocus);
225 q->initStyleOption(&
opt);
238 q->setMouseTracking(
true);
239 q->setAcceptDrops(
true);
255 q->initStyleOption(&
opt);
289 if (
q->hasFocus() &&
qApp) {
322#if QT_CONFIG(draganddrop)
323void QLineEditPrivate::drag()
338#if QT_CONFIG(toolbutton)
339QLineEditIconButton::QLineEditIconButton(
QWidget *parent)
348 QLineEdit *
le = qobject_cast<QLineEdit *>(parentWidget());
359 const int iconWidth = lep ? lep->sideWidgetParameters().iconSize : 16;
372 const auto *action = e->action();
373 if (isVisibleTo(parentWidget()) != action->isVisible()) {
374 setVisible(action->isVisible());
376 lep->positionSideWidgets();
386void QLineEditIconButton::setOpacity(
qreal value)
395#if QT_CONFIG(animation)
396bool QLineEditIconButton::shouldHideWithText()
const
398 return m_hideWithText;
401void QLineEditIconButton::setHideWithText(
bool hide)
403 m_hideWithText =
hide;
406void QLineEditIconButton::onAnimationFinished()
408 if (shouldHideWithText() &&
isVisible() && m_fadingOut) {
413 if (
auto le = lineEditPrivate())
414 le->updateGeometry_helper(
true);
418void QLineEditIconButton::animateShow(
bool visible)
420 m_fadingOut = !visible;
422 if (shouldHideWithText() && !
isVisible()) {
426 if (
auto le = lineEditPrivate())
427 le->updateGeometry_helper(
true);
430 startOpacityAnimation(visible ? 1.0 : 0.0);
433void QLineEditIconButton::startOpacityAnimation(
qreal endValue)
444void QLineEditIconButton::updateCursor()
452#if QT_CONFIG(animation) && QT_CONFIG(toolbutton)
455 for (
const auto &e :
widgets) {
457 static_cast<QLineEditIconButton *
>(e.widget)->animateShow(
display);
464 if (hasSideWidgets()) {
465 const int newTextSize =
text.
size();
466 if (!newTextSize || !lastTextSize) {
467 lastTextSize = newTextSize;
468#if QT_CONFIG(animation) && QT_CONFIG(toolbutton)
469 const bool display = newTextSize > 0;
470 displayWidgets(leadingSideWidgets,
display);
471 displayWidgets(trailingSideWidgets,
display);
480 if (!
q->text().isEmpty()) {
490 emit q->returnPressed();
491 emit q->editingFinished();
509 q->initStyleOption(&styleOption);
517 if (e.flags & SideWidgetClearButton) {
530 if (hasSideWidgets()) {
531 const QRect contentRect =
q->rect();
533 const int delta =
p.margin +
p.widgetWidth;
535 QSize(
p.widgetWidth,
p.widgetHeight));
537 e.widget->setGeometry(widgetGeometry);
539 if (e.action->isVisible())
540 widgetGeometry.moveLeft(widgetGeometry.left() + delta);
545 widgetGeometry.moveLeft(contentRect.
width() -
p.widgetWidth -
p.margin);
547 e.widget->setGeometry(widgetGeometry);
549 if (e.action->isVisible())
550 widgetGeometry.moveLeft(widgetGeometry.left() - delta);
557QLineEditPrivate::SideWidgetLocation QLineEditPrivate::findSideWidget(
const QAction *
a)
const
560 for (
const auto &e : leadingSideWidgets) {
566 for (
const auto &e : trailingSideWidgets) {
579 if (!hasSideWidgets()) {
582 lastTextSize =
q->text().size();
587 if (
QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(newAction)) {
588 if ((
w = widgetAction->requestWidget(
q)))
589 flags |= SideWidgetCreatedByWidgetAction;
592#if QT_CONFIG(toolbutton)
593 QLineEditIconButton *toolButton =
new QLineEditIconButton(
q);
594 toolButton->setIcon(newAction->icon());
595 toolButton->setOpacity(lastTextSize > 0 || !(
flags & SideWidgetFadeInWithText) ? 1 : 0);
596 if (
flags & SideWidgetClearButton) {
600#if QT_CONFIG(animation)
603 toolButton->setHideWithText(
true);
606 toolButton->setDefaultAction(newAction);
615 for (
const SideWidgetEntry &e : trailingSideWidgets) {
616 if (e.flags & SideWidgetClearButton) {
632 const SideWidgetLocation loc = {
position, -1};
633 const auto location = before ? findSideWidget(before) : loc;
635 const auto location = before ? findSideWidget(before) : SideWidgetLocation{
position, -1};
640 SideWidgetEntry(
w, newAction,
flags));
641 positionSideWidgets();
646void QLineEditPrivate::removeAction(
QAction *action)
649 const auto location = findSideWidget(action);
655 if (
entry.flags & SideWidgetCreatedByWidgetAction)
659 positionSideWidgets();
660 if (!hasSideWidgets())
671 return defaultMargin;
675#if QT_CONFIG(toolbutton) && QT_CONFIG(animation)
677 if (auto* iconButton = qobject_cast<QLineEditIconButton*>(e.widget))
678 return iconButton->needsSpace();
681 return e.widget->isVisibleTo(e.widget->parentWidget());
684 return defaultMargin + (parameters.
margin + parameters.
widgetWidth) * visibleSideWidgetCount;
689 return {
effectiveTextMargin(textMargins.left(), leftSideWidgetList(), sideWidgetParameters()),
692 textMargins.bottom()};
698#include "moc_qlineedit_p.cpp"
void start(QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
Starts the animation.
void finished()
QAbstractAnimation emits this signal after the animation has stopped and has reached the end.
The QActionEvent class provides an event that is generated when a QAction is added,...
The QAction class provides an abstraction for user commands that can be added to different user inter...
void highlighted(const QString &text)
This signal is sent when an item in the popup() is highlighted by the user.
void activated(const QString &text)
This signal is sent when an item in the popup() is activated by the user (by clicking or pressing ret...
The QCursor class provides a mouse cursor with an arbitrary shape.
Qt::DropAction exec(Qt::DropActions supportedActions=Qt::MoveAction)
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
QObject * target() const
Returns the target of the drag and drop operation.
Type type() const
Returns the event type.
static QStyleHints * styleHints()
Returns the application's style hints.
static QInputMethod * inputMethod()
returns the input method.
The QIcon class provides scalable icons in different modes and states.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
void handleWindowActivate()
QRect adjustedControlRect(const QRect &) const
void textChanged(const QString &)
void positionSideWidgets()
QString textAfterCursor(int curPos) const
void setClearButtonEnabled(bool enabled)
void textEdited(const QString &)
void init(const QString &)
static const int horizontalMargin
static const int verticalMargin
QWidgetLineControl * control
void clearButtonClicked()
void updatePasswordEchoEditing(bool)
@ SideWidgetFadeInWithText
void initMouseYThreshold()
QIcon clearButtonIcon() const
bool shouldEnableInputMethod() const
QMargins effectiveTextMargins() const
void controlEditingFinished()
void cursorPositionChanged(int, int)
QRect adjustedContentsRect() const
void updateNeeded(const QRect &)
bool sendMouseEventToInputContext(QMouseEvent *e)
This function is not intended as polymorphic usage.
QString textBeforeCursor(int curPos) const
void setText(const QString &text)
void setCursorVisible(bool visible)
SideWidgetParameters sideWidgetParameters() const
std::vector< SideWidgetEntry > SideWidgetEntryList
int xToPos(int x, QTextLine::CursorPosition=QTextLine::CursorBetweenCharacters) const
bool inSelection(int x) const
The QLineEdit widget is a one-line text editor.
ActionPosition
This enum type describes how a line edit should display the action widgets to be added.
void textChanged(const QString &)
This signal is emitted whenever the text changes.
void setText(const QString &)
iterator erase(const_iterator begin, const_iterator end)
iterator insert(qsizetype i, parameter_type t)
bool empty() const noexcept
void setText(const QString &text)
Sets text as the plain text (MIME type text/plain) used to represent the data.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setParent(QObject *parent)
Makes the object a child of parent.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
void setOpacity(qreal opacity)
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr QRect marginsRemoved(const QMargins &margins) const noexcept
Removes the margins from the rectangle, shrinking it.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
\variable QStyleOptionFocusRect::backgroundColor
@ SH_LineEdit_PasswordMaskDelay
@ SH_LineEdit_PasswordCharacter
@ SH_BlinkCursorWhenTextSelected
CursorPosition
\value CursorBetweenCharacters \value CursorOnCharacter
void setDuration(int msecs)
void setEndValue(const QVariant &value)
struct wl_display * display
Combined button and popup list for selecting options.
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
#define QByteArrayLiteral(str)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
static int effectiveTextMargin(int defaultMargin, const QLineEditPrivate::SideWidgetEntryList &widgets, const QLineEditPrivate::SideWidgetParameters ¶meters)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLdouble GLdouble GLdouble GLdouble q
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QList< QWidget * > widgets
[11]
item setCursor(Qt::IBeamCursor)
[1]