Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qlineedit_p.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qlineedit.h"
5#include "qlineedit_p.h"
6
7#include "qvariant.h"
8#if QT_CONFIG(itemviews)
9#include "qabstractitemview.h"
10#endif
11#if QT_CONFIG(draganddrop)
12#include "qdrag.h"
13#endif
14#if QT_CONFIG(action)
15# include "qwidgetaction.h"
16#endif
17#include "qclipboard.h"
18#if QT_CONFIG(accessibility)
19#include "qaccessible.h"
20#endif
21#ifndef QT_NO_IM
22#include "qinputmethod.h"
23#include "qlist.h"
24#endif
25#include <qpainter.h>
26#if QT_CONFIG(animation)
27#include <qpropertyanimation.h>
28#endif
29#include <qstylehints.h>
30#include <qvalidator.h>
31
33
36
37// Needs to be kept in sync with QLineEdit::paintEvent
39{
40 QRect widgetRect = !rect.isEmpty() ? rect : q_func()->rect();
42 int cix = cr.x() - hscroll + horizontalMargin;
43 return widgetRect.translated(QPoint(cix, vscroll - control->ascent() + q_func()->fontMetrics().ascent()));
44}
45
47{
49 x-= cr.x() - hscroll + horizontalMargin;
50 return control->xToPos(x, betweenOrOn);
51}
52
54{
55 const QString &text = control->text();
56 return text.mid(0, curPos);
57}
58
60{
61 const QString &text = control->text();
62 return text.mid(curPos);
63}
64
66{
68 return control->inSelection(x);
69}
70
72{
74}
75
76#if QT_CONFIG(completer)
77
78void QLineEditPrivate::_q_completionHighlighted(const QString &newText)
79{
80 Q_Q(QLineEdit);
81 if (control->completer()->completionMode() != QCompleter::InlineCompletion) {
82 q->setText(newText);
83 } else {
84 int c = control->cursor();
86 q->setText(QStringView{text}.left(c) + QStringView{newText}.mid(c));
87 control->moveCursor(control->end(), false);
88#ifndef Q_OS_ANDROID
89 const bool mark = true;
90#else
91 const bool mark = (imHints & Qt::ImhNoPredictiveText);
92#endif
93 control->moveCursor(c, mark);
94 }
95}
96
97#endif // QT_CONFIG(completer)
98
100{
101 Q_Q(QLineEdit);
102 if (!q->hasFocus() && control->hasSelectedText())
103 control->deselect();
104}
105
107{
108 Q_Q(QLineEdit);
109 edited = true;
110 emit q->textEdited(text);
111#if QT_CONFIG(completer)
112 if (control->completer()
113 && control->completer()->completionMode() != QCompleter::InlineCompletion)
114 control->complete(-1); // update the popup on cut/paste/del
115#endif
116}
117
119{
120 Q_Q(QLineEdit);
121 q->update();
122 emit q->cursorPositionChanged(from, to);
123}
124
125#ifdef QT_KEYPAD_NAVIGATION
126void QLineEditPrivate::_q_editFocusChange(bool e)
127{
128 Q_Q(QLineEdit);
129 q->setEditFocus(e);
130}
131#endif
132
134{
135 Q_Q(QLineEdit);
138 q->initStyleOption(&opt);
139 bool showCursor = control->hasSelectedText() ?
140 q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
141 q->hasFocus();
142 setCursorVisible(showCursor);
143 }
144
145 emit q->selectionChanged();
146#if QT_CONFIG(accessibility)
147 QAccessibleTextSelectionEvent ev(q, control->selectionStart(), control->selectionEnd());
148 ev.setCursorPosition(control->cursorPosition());
149 QAccessible::updateAccessibility(&ev);
150#endif
151}
152
154{
155 q_func()->update(adjustedControlRect(rect));
156}
157
159{
160 Q_Q(QLineEdit);
163 control->setFont(q->font());
168 QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
169 q, SLOT(_q_cursorPositionChanged(int,int)));
170 QObject::connect(control, SIGNAL(selectionChanged()),
172 QObject::connect(control, SIGNAL(editingFinished()),
174#ifdef QT_KEYPAD_NAVIGATION
175 QObject::connect(control, SIGNAL(editFocusChange(bool)),
176 q, SLOT(_q_editFocusChange(bool)));
177#endif
178 QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
179 q, SLOT(updateMicroFocus()));
180
182 q, SLOT(updateMicroFocus()));
183
184 QObject::connect(control, SIGNAL(updateMicroFocus()),
185 q, SLOT(updateMicroFocus()));
186
187 // for now, going completely overboard with updates.
188 QObject::connect(control, SIGNAL(selectionChanged()),
189 q, SLOT(update()));
190
191 QObject::connect(control, SIGNAL(selectionChanged()),
192 q, SLOT(updateMicroFocus()));
193
194 QObject::connect(control, SIGNAL(displayTextChanged(QString)),
195 q, SLOT(update()));
196
197 QObject::connect(control, SIGNAL(updateNeeded(QRect)),
199 QObject::connect(control, SIGNAL(inputRejected()), q, SIGNAL(inputRejected()));
200
202 q->initStyleOption(&opt);
203 control->setPasswordCharacter(char16_t(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q)));
205#ifndef QT_NO_CURSOR
206 q->setCursor(Qt::IBeamCursor);
207#endif
208 q->setFocusPolicy(Qt::StrongFocus);
209 q->setAttribute(Qt::WA_InputMethodEnabled);
210 // Specifies that this widget can use more, but is able to survive on
211 // less, horizontal space; and is fixed vertically.
213 q->setBackgroundRole(QPalette::Base);
214 q->setAttribute(Qt::WA_KeyCompression);
215 q->setMouseTracking(true);
216 q->setAcceptDrops(true);
217
218 q->setAttribute(Qt::WA_MacShowFocusRect);
219
221}
222
224{
226}
227
229{
230 Q_Q(const QLineEdit);
232 q->initStyleOption(&opt);
233 QRect r = q->style()->subElementRect(QStyle::SE_LineEditContents, &opt, q);
235 return r;
236}
237
239{
240 Q_Q(QLineEdit);
241 if ((bool)cursorVisible == visible)
242 return;
243 cursorVisible = visible;
244 if (control->inputMask().isEmpty())
245 q->update(cursorRect());
246 else
247 q->update();
248}
249
251{
252 edited = true;
254}
255
257{
258 Q_Q(QLineEdit);
261}
262
264{
265 Q_Q(QLineEdit);
266 if (q->hasFocus() && qApp) {
268 }
269}
270
277{
278#if !defined QT_NO_IM
279 if ( control->composeMode() ) {
280 int tmp_cursor = xToPos(e->position().toPoint().x());
281 int mousePos = tmp_cursor - control->cursor();
282 if ( mousePos < 0 || mousePos > control->preeditAreaText().size() )
283 mousePos = -1;
284
285 if (mousePos >= 0) {
286 if (e->type() == QEvent::MouseButtonRelease)
288
289 return true;
290 }
291 }
292#else
293 Q_UNUSED(e);
294#endif
295
296 return false;
297}
298
299#if QT_CONFIG(draganddrop)
300void QLineEditPrivate::drag()
301{
302 Q_Q(QLineEdit);
303 dndTimer.stop();
304 QMimeData *data = new QMimeData;
306 QDrag *drag = new QDrag(q);
307 drag->setMimeData(data);
308 Qt::DropAction action = drag->exec(Qt::CopyAction);
309 if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
311}
312#endif // QT_CONFIG(draganddrop)
313
314
315#if QT_CONFIG(toolbutton)
316QLineEditIconButton::QLineEditIconButton(QWidget *parent)
318 , m_opacity(0)
319{
320 setFocusPolicy(Qt::NoFocus);
321}
322
323QLineEditPrivate *QLineEditIconButton::lineEditPrivate() const
324{
325 QLineEdit *le = qobject_cast<QLineEdit *>(parentWidget());
326 return le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : nullptr;
327}
328
329void QLineEditIconButton::paintEvent(QPaintEvent *)
330{
331 QPainter painter(this);
333 if (isEnabled())
334 state = isDown() ? QIcon::Active : QIcon::Normal;
335 const QLineEditPrivate *lep = lineEditPrivate();
336 const int iconWidth = lep ? lep->sideWidgetParameters().iconSize : 16;
337 const QSize iconSize(iconWidth, iconWidth);
338 const QPixmap iconPixmap = icon().pixmap(iconSize, devicePixelRatio(), state, QIcon::Off);
339 QRect pixmapRect = QRect(QPoint(0, 0), iconSize);
340 pixmapRect.moveCenter(rect().center());
341 painter.setOpacity(m_opacity);
342 painter.drawPixmap(pixmapRect, iconPixmap);
343}
344
345void QLineEditIconButton::actionEvent(QActionEvent *e)
346{
347 switch (e->type()) {
349 const auto *action = e->action();
350 if (isVisibleTo(parentWidget()) != action->isVisible()) {
351 setVisible(action->isVisible());
352 if (QLineEditPrivate *lep = lineEditPrivate())
353 lep->positionSideWidgets();
354 }
355 }
356 break;
357 default:
358 break;
359 }
361}
362
363void QLineEditIconButton::setOpacity(qreal value)
364{
365 if (!qFuzzyCompare(m_opacity, value)) {
366 m_opacity = value;
367 updateCursor();
368 update();
369 }
370}
371
372#if QT_CONFIG(animation)
373bool QLineEditIconButton::shouldHideWithText() const
374{
375 return m_hideWithText;
376}
377
378void QLineEditIconButton::setHideWithText(bool hide)
379{
380 m_hideWithText = hide;
381}
382
383void QLineEditIconButton::onAnimationFinished()
384{
385 if (shouldHideWithText() && isVisible() && m_fadingOut) {
386 hide();
387 m_fadingOut = false;
388
389 // Invalidate previous geometry to take into account new size of side widgets
390 if (auto le = lineEditPrivate())
391 le->updateGeometry_helper(true);
392 }
393}
394
395void QLineEditIconButton::animateShow(bool visible)
396{
397 m_fadingOut = !visible;
398
399 if (shouldHideWithText() && !isVisible()) {
400 show();
401
402 // Invalidate previous geometry to take into account new size of side widgets
403 if (auto le = lineEditPrivate())
404 le->updateGeometry_helper(true);
405 }
406
407 startOpacityAnimation(visible ? 1.0 : 0.0);
408}
409
410void QLineEditIconButton::startOpacityAnimation(qreal endValue)
411{
413 connect(animation, &QPropertyAnimation::finished, this, &QLineEditIconButton::onAnimationFinished);
414
416 animation->setEndValue(endValue);
418}
419#endif
420
421void QLineEditIconButton::updateCursor()
422{
423#ifndef QT_NO_CURSOR
424 setCursor(qFuzzyCompare(m_opacity, qreal(1.0)) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor());
425#endif
426}
427#endif // QT_CONFIG(toolbutton)
428
429#if QT_CONFIG(animation) && QT_CONFIG(toolbutton)
430static void displayWidgets(const QLineEditPrivate::SideWidgetEntryList &widgets, bool display)
431{
432 for (const auto &e : widgets) {
434 static_cast<QLineEditIconButton *>(e.widget)->animateShow(display);
435 }
436}
437#endif
438
440{
441 if (hasSideWidgets()) {
442 const int newTextSize = text.size();
443 if (!newTextSize || !lastTextSize) {
444 lastTextSize = newTextSize;
445#if QT_CONFIG(animation) && QT_CONFIG(toolbutton)
446 const bool display = newTextSize > 0;
447 displayWidgets(leadingSideWidgets, display);
448 displayWidgets(trailingSideWidgets, display);
449#endif
450 }
451 }
452}
453
455{
456 Q_Q(QLineEdit);
457 if (!q->text().isEmpty()) {
458 q->clear();
460 }
461}
462
464{
465 Q_Q(QLineEdit);
466 edited = false;
467 emit q->returnPressed();
468 emit q->editingFinished();
469}
470
472{
473 Q_Q(const QLineEdit);
475 result.iconSize = q->style()->pixelMetric(QStyle::PM_LineEditIconSize, nullptr, q);
476 result.margin = q->style()->pixelMetric(QStyle::PM_LineEditIconMargin, nullptr, q);
477 result.widgetWidth = result.iconSize + 6;
478 result.widgetHeight = result.iconSize + 2;
479 return result;
480}
481
483{
484 Q_Q(const QLineEdit);
485 QStyleOptionFrame styleOption;
486 q->initStyleOption(&styleOption);
487 return q->style()->standardIcon(QStyle::SP_LineEditClearButton, &styleOption, q);
488}
489
491{
492#if QT_CONFIG(action)
493 for (const SideWidgetEntry &e : trailingSideWidgets) {
494 if (e.flags & SideWidgetClearButton) {
495 e.action->setEnabled(enabled);
496 break;
497 }
498 }
499#else
501#endif
502}
503
505{
506 Q_Q(QLineEdit);
507 if (hasSideWidgets()) {
508 const QRect contentRect = q->rect();
510 const int delta = p.margin + p.widgetWidth;
511 QRect widgetGeometry(QPoint(p.margin, (contentRect.height() - p.widgetHeight) / 2),
512 QSize(p.widgetWidth, p.widgetHeight));
513 for (const SideWidgetEntry &e : leftSideWidgetList()) {
514 e.widget->setGeometry(widgetGeometry);
515#if QT_CONFIG(action)
516 if (e.action->isVisible())
517 widgetGeometry.moveLeft(widgetGeometry.left() + delta);
518#else
519 Q_UNUSED(delta);
520#endif
521 }
522 widgetGeometry.moveLeft(contentRect.width() - p.widgetWidth - p.margin);
523 for (const SideWidgetEntry &e : rightSideWidgetList()) {
524 e.widget->setGeometry(widgetGeometry);
525#if QT_CONFIG(action)
526 if (e.action->isVisible())
527 widgetGeometry.moveLeft(widgetGeometry.left() - delta);
528#endif
529 }
530 }
531}
532
533#if QT_CONFIG(action)
534QLineEditPrivate::SideWidgetLocation QLineEditPrivate::findSideWidget(const QAction *a) const
535{
536 int i = 0;
537 for (const auto &e : leadingSideWidgets) {
538 if (a == e.action)
540 ++i;
541 }
542 i = 0;
543 for (const auto &e : trailingSideWidgets) {
544 if (a == e.action)
546 ++i;
547 }
548 return {QLineEdit::LeadingPosition, -1};
549}
550
551QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition position, int flags)
552{
553 Q_Q(QLineEdit);
554 if (!newAction)
555 return nullptr;
556 if (!hasSideWidgets()) { // initial setup.
558 lastTextSize = q->text().size();
559 }
560 QWidget *w = nullptr;
561 // Store flags about QWidgetAction here since removeAction() may be called from ~QAction,
562 // in which a qobject_cast<> no longer works.
563 if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(newAction)) {
564 if ((w = widgetAction->requestWidget(q)))
566 }
567 if (!w) {
568#if QT_CONFIG(toolbutton)
569 QLineEditIconButton *toolButton = new QLineEditIconButton(q);
570 toolButton->setIcon(newAction->icon());
571 toolButton->setOpacity(lastTextSize > 0 || !(flags & SideWidgetFadeInWithText) ? 1 : 0);
573 QObject::connect(toolButton, SIGNAL(clicked()), q, SLOT(_q_clearButtonClicked()));
574
575#if QT_CONFIG(animation)
576 // The clear button is handled only by this widget. The button should be really
577 // shown/hidden in order to calculate size hints correctly.
578 toolButton->setHideWithText(true);
579#endif
580 }
581 toolButton->setDefaultAction(newAction);
582 w = toolButton;
583#else
584 return nullptr;
585#endif
586 }
587
588 // QTBUG-59957: clear button should be the leftmost action.
590 for (const SideWidgetEntry &e : trailingSideWidgets) {
591 if (e.flags & SideWidgetClearButton) {
592 before = e.action;
593 break;
594 }
595 }
596 }
597
598 // If there is a 'before' action, it takes preference
599
600 // There's a bug in GHS compiler that causes internal error on the following code.
601 // The affected GHS compiler versions are 2016.5.4 and 2017.1. GHS internal reference
602 // to track the progress of this issue is TOOLS-26637.
603 // This temporary workaround allows to compile with GHS toolchain and should be
604 // removed when GHS provides a patch to fix the compiler issue.
605
606#if defined(Q_CC_GHS)
607 const SideWidgetLocation loc = {position, -1};
608 const auto location = before ? findSideWidget(before) : loc;
609#else
610 const auto location = before ? findSideWidget(before) : SideWidgetLocation{position, -1};
611#endif
612
613 SideWidgetEntryList &list = location.position == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets;
614 list.insert(location.isValid() ? list.begin() + location.index : list.end(),
615 SideWidgetEntry(w, newAction, flags));
617 w->show();
618 return w;
619}
620
621void QLineEditPrivate::removeAction(QAction *action)
622{
623 Q_Q(QLineEdit);
624 const auto location = findSideWidget(action);
625 if (!location.isValid())
626 return;
627 SideWidgetEntryList &list = location.position == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets;
628 SideWidgetEntry entry = list[location.index];
629 list.erase(list.begin() + location.index);
631 static_cast<QWidgetAction *>(entry.action)->releaseWidget(entry.widget);
632 else
633 delete entry.widget;
635 if (!hasSideWidgets()) // Last widget, remove connection
637 q->update();
638}
639#endif // QT_CONFIG(action)
640
643{
644 if (widgets.empty())
645 return defaultMargin;
646
647 const auto visibleSideWidgetCount = std::count_if(widgets.begin(), widgets.end(),
649#if QT_CONFIG(toolbutton) && QT_CONFIG(animation)
650 // a button that's fading out doesn't get any space
651 if (auto* iconButton = qobject_cast<QLineEditIconButton*>(e.widget))
652 return iconButton->needsSpace();
653
654#endif
655 return e.widget->isVisibleTo(e.widget->parentWidget());
656 });
657
658 return defaultMargin + (parameters.margin + parameters.widgetWidth) * visibleSideWidgetCount;
659}
660
662{
667}
668
669
671
672#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...
Definition qaction.h:30
QIcon icon
the action's icon
Definition qaction.h:38
@ InlineCompletion
Definition qcompleter.h:40
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
\inmodule QtGui
Definition qdrag.h:22
Qt::DropAction exec(Qt::DropActions supportedActions=Qt::MoveAction)
Definition qdrag.cpp:199
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
Definition qdrag.cpp:99
QObject * target() const
Returns the target of the drag and drop operation.
Definition qdrag.cpp:176
@ ActionChanged
Definition qcoreevent.h:151
@ MouseButtonRelease
Definition qcoreevent.h:61
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.
Definition qicon.h:20
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
@ Disabled
Definition qicon.h:22
@ Normal
Definition qicon.h:22
@ Active
Definition qicon.h:22
@ Off
Definition qicon.h:23
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.
Definition qicon.cpp:788
void invokeAction(Action a, int cursorPosition)
Called by the input item when the word currently being composed is tapped by the user,...
void reset()
Resets the input method state.
QRect adjustedControlRect(const QRect &) const
QString textAfterCursor(int curPos) const
void _q_controlEditingFinished()
void _q_textEdited(const QString &)
void setClearButtonEnabled(bool enabled)
void _q_clearButtonClicked()
void init(const QString &)
static const int horizontalMargin
static const int verticalMargin
QWidgetLineControl * control
void updatePasswordEchoEditing(bool)
@ SideWidgetCreatedByWidgetAction
void _q_updateNeeded(const QRect &)
QIcon clearButtonIcon() const
bool shouldEnableInputMethod() const
QMargins effectiveTextMargins() const
void _q_cursorPositionChanged(int, int)
void _q_handleWindowActivate()
QRect adjustedContentsRect() const
const SideWidgetEntryList & leftSideWidgetList() const
QMargins textMargins
const SideWidgetEntryList & rightSideWidgetList() const
QRect cursorRect() const
void _q_textChanged(const QString &)
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
bool hasSideWidgets() 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.
Definition qlineedit.h:28
ActionPosition
This enum type describes how a line edit should display the action widgets to be added.
Definition qlineedit.h:51
@ TrailingPosition
Definition qlineedit.h:53
@ LeadingPosition
Definition qlineedit.h:52
iterator erase(const_iterator begin, const_iterator end)
Definition qlist.h:882
iterator insert(qsizetype i, parameter_type t)
Definition qlist.h:471
bool empty() const noexcept
Definition qlist.h:682
iterator end()
Definition qlist.h:609
iterator begin()
Definition qlist.h:608
\inmodule QtCore
Definition qmargins.h:23
constexpr int bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:119
constexpr int left() const noexcept
Returns the left margin.
Definition qmargins.h:110
constexpr int right() const noexcept
Returns the right margin.
Definition qmargins.h:116
constexpr int top() const noexcept
Returns the top margin.
Definition qmargins.h:113
\inmodule QtCore
Definition qmimedata.h:16
void setText(const QString &text)
Sets text as the plain text (MIME type text/plain) used to represent the data.
\inmodule QtGui
Definition qevent.h:195
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2142
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3099
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:485
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
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...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr void moveCenter(const QPoint &p) noexcept
Moves the rectangle, leaving the center point at the given position.
Definition qrect.h:327
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:238
constexpr QRect marginsRemoved(const QMargins &margins) const noexcept
Removes the margins from the rectangle, shrinking it.
Definition qrect.h:453
constexpr void moveLeft(int pos) noexcept
Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate.
Definition qrect.h:285
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:172
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:184
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:235
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
Definition qrect.h:260
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
Definition qstringview.h:76
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
qsizetype size() const
Returns the number of characters in this string.
Definition qstring.h:182
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
Definition qstring.cpp:5204
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
Definition qstring.cpp:5161
int mouseQuickSelectionThreshold
Quick selection mouse threshold in QLineEdit.
Definition qstylehints.h:51
\variable QStyleOptionFocusRect::backgroundColor
@ SH_LineEdit_PasswordMaskDelay
Definition qstyle.h:688
@ SH_LineEdit_PasswordCharacter
Definition qstyle.h:618
@ SH_BlinkCursorWhenTextSelected
Definition qstyle.h:611
@ SP_LineEditClearButton
Definition qstyle.h:785
@ PM_LineEditIconMargin
Definition qstyle.h:535
@ PM_LineEditIconSize
Definition qstyle.h:534
@ SE_LineEditContents
Definition qstyle.h:281
CursorPosition
\value CursorBetweenCharacters \value CursorOnCharacter
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition qtoolbutton.h:20
void actionEvent(QActionEvent *) override
\reimp
void setDuration(int msecs)
void setEndValue(const QVariant &value)
The QWidgetAction class extends QAction by an interface for inserting custom widgets into action base...
void setText(const QString &txt)
void setFont(const QFont &font)
void updatePasswordEchoEditing(bool editing)
void moveCursor(int pos, bool mark=false)
int xToPos(int x, QTextLine::CursorPosition=QTextLine::CursorBetweenCharacters) const
bool inSelection(int x) const
QString selectedText() const
void setPasswordMaskDelay(int delay)
QString preeditAreaText() const
void setPasswordCharacter(QChar character)
void update(T t)
Qt::InputMethodHints imHints
Definition qwidget_p.h:656
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QString text
QCursor cursor
void textChanged(const QString &newText)
double e
opt iconSize
rect
[4]
QStyleOptionButton opt
fontMetrics
else opt state
[0]
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
bool isEnabled()
@ WA_KeyCompression
Definition qnamespace.h:299
@ WA_MacShowFocusRect
Definition qnamespace.h:358
@ WA_InputMethodEnabled
Definition qnamespace.h:294
@ NoFocus
Definition qnamespace.h:106
@ StrongFocus
Definition qnamespace.h:109
@ ArrowCursor
@ IBeamCursor
@ ImhNoPredictiveText
DropAction
@ CopyAction
@ MoveAction
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
#define qApp
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:287
static int effectiveTextMargin(int defaultMargin, const QLineEditPrivate::SideWidgetEntryList &widgets, const QLineEditPrivate::SideWidgetParameters &parameters)
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLint location
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLboolean r
[2]
GLuint GLuint end
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
const GLubyte * c
GLuint entry
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define emit
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:92
Q_WIDGETS_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
view show()
[18] //! [19]
QList< int > list
[14]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QList< QWidget * > widgets
[11]
QObject::connect nullptr
QPropertyAnimation animation
[0]
Text files * txt
item setCursor(Qt::IBeamCursor)
[1]
edit hide()
edit isVisible()
QPointer< QLineEdit > le
QPainter painter(this)
[7]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent