Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
70
75
76#if QT_CONFIG(completer)
77void QLineEditPrivate::connectCompleter()
78{
79 Q_Q(const QLineEdit);
80 QObject::connect(control->completer(), qOverload<const QString &>(&QCompleter::activated),
82 QObjectPrivate::connect(control->completer(), qOverload<const QString &>(&QCompleter::highlighted),
83 this, &QLineEditPrivate::completionHighlighted);
84}
85
86void QLineEditPrivate::disconnectCompleter()
87{
88 Q_Q(const QLineEdit);
89 QObject::disconnect(control->completer(), qOverload<const QString &>(&QCompleter::activated),
91 QObjectPrivate::disconnect(control->completer(), qOverload<const QString &>(&QCompleter::highlighted),
92 this, &QLineEditPrivate::completionHighlighted);
93}
94
95void QLineEditPrivate::completionHighlighted(const QString &newText)
96{
97 Q_Q(QLineEdit);
98 if (control->completer()->completionMode() != QCompleter::InlineCompletion) {
99 q->setText(newText);
100 } else {
101 int c = control->cursor();
103 q->setText(QStringView{text}.left(c) + QStringView{newText}.mid(c));
104 control->moveCursor(control->end(), false);
105#ifndef Q_OS_ANDROID
106 const bool mark = true;
107#else
108 const bool mark = (imHints & Qt::ImhNoPredictiveText);
109#endif
110 control->moveCursor(c, mark);
111 }
112}
113
114#endif // QT_CONFIG(completer)
115
117{
118 Q_Q(QLineEdit);
119 if (!q->hasFocus() && control->hasSelectedText())
120 control->deselect();
121}
122
124{
125 Q_Q(QLineEdit);
126 edited = true;
127 emit q->textEdited(text);
128#if QT_CONFIG(completer)
129 if (control->completer()
130 && control->completer()->completionMode() != QCompleter::InlineCompletion)
131 control->complete(-1); // update the popup on cut/paste/del
132#endif
133}
134
136{
137 Q_Q(QLineEdit);
138 q->update();
139 emit q->cursorPositionChanged(from, to);
140}
141
142#ifdef QT_KEYPAD_NAVIGATION
143void QLineEditPrivate::editFocusChange(bool e)
144{
145 Q_Q(QLineEdit);
146 q->setEditFocus(e);
147}
148#endif
149
151{
152 Q_Q(QLineEdit);
155 q->initStyleOption(&opt);
156 bool showCursor = control->hasSelectedText() ?
157 q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
158 q->hasFocus();
159 setCursorVisible(showCursor);
160 }
161
162 emit q->selectionChanged();
163#if QT_CONFIG(accessibility)
164 QAccessibleTextSelectionEvent ev(q, control->selectionStart(), control->selectionEnd());
165 ev.setCursorPosition(control->cursorPosition());
166 QAccessible::updateAccessibility(&ev);
167#endif
168}
169
171{
172 q_func()->update(adjustedControlRect(rect));
173}
174
176{
177 Q_Q(QLineEdit);
178
179 const auto qUpdateMicroFocus = [q]()
180 {
181 q->updateMicroFocus();
182 };
185 control->setFont(q->font());
196#ifdef QT_KEYPAD_NAVIGATION
197 QObject::connect(control, &QWidgetLineControl::editFocusChange,
198 this, &QLineEditPrivate::editFocusChange);
199#endif
201 q, qUpdateMicroFocus);
202
204 q, qUpdateMicroFocus);
205
207 q, qUpdateMicroFocus);
208
209 // for now, going completely overboard with updates.
211 q, qOverload<>(&QLineEdit::update));
212
214 q, qUpdateMicroFocus);
215
217 q, qOverload<>(&QLineEdit::update));
218
223
225 q->initStyleOption(&opt);
226 control->setPasswordCharacter(char16_t(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q)));
228#ifndef QT_NO_CURSOR
229 q->setCursor(Qt::IBeamCursor);
230#endif
231 q->setFocusPolicy(Qt::StrongFocus);
232 q->setAttribute(Qt::WA_InputMethodEnabled);
233 // Specifies that this widget can use more, but is able to survive on
234 // less, horizontal space; and is fixed vertically.
236 q->setBackgroundRole(QPalette::Base);
237 q->setAttribute(Qt::WA_KeyCompression);
238 q->setMouseTracking(true);
239 q->setAcceptDrops(true);
240
241 q->setAttribute(Qt::WA_MacShowFocusRect);
242
244}
245
247{
248 mouseYThreshold = QGuiApplication::styleHints()->mouseQuickSelectionThreshold();
249}
250
252{
253 Q_Q(const QLineEdit);
255 q->initStyleOption(&opt);
256 QRect r = q->style()->subElementRect(QStyle::SE_LineEditContents, &opt, q);
258 return r;
259}
260
262{
263 Q_Q(QLineEdit);
264 if ((bool)cursorVisible == visible)
265 return;
266 cursorVisible = visible;
267 if (control->inputMask().isEmpty())
268 q->update(cursorRect());
269 else
270 q->update();
271}
272
274{
275 edited = true;
277}
278
285
287{
288 Q_Q(QLineEdit);
289 if (q->hasFocus() && qApp) {
291 }
292}
293
300{
301#if !defined QT_NO_IM
302 if ( control->composeMode() ) {
303 int tmp_cursor = xToPos(e->position().toPoint().x());
304 int mousePos = tmp_cursor - control->cursor();
305 if ( mousePos < 0 || mousePos > control->preeditAreaText().size() )
306 mousePos = -1;
307
308 if (mousePos >= 0) {
310 QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, mousePos);
311
312 return true;
313 }
314 }
315#else
316 Q_UNUSED(e);
317#endif
318
319 return false;
320}
321
322#if QT_CONFIG(draganddrop)
323void QLineEditPrivate::drag()
324{
325 Q_Q(QLineEdit);
326 dndTimer.stop();
327 QMimeData *data = new QMimeData;
329 QDrag *drag = new QDrag(q);
330 drag->setMimeData(data);
331 Qt::DropAction action = drag->exec(Qt::CopyAction);
332 if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
334}
335#endif // QT_CONFIG(draganddrop)
336
337
338#if QT_CONFIG(toolbutton)
339QLineEditIconButton::QLineEditIconButton(QWidget *parent)
340 : QToolButton(parent)
341 , m_opacity(0)
342{
343 setFocusPolicy(Qt::NoFocus);
344}
345
346QLineEditPrivate *QLineEditIconButton::lineEditPrivate() const
347{
348 QLineEdit *le = qobject_cast<QLineEdit *>(parentWidget());
349 return le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : nullptr;
350}
351
352void QLineEditIconButton::paintEvent(QPaintEvent *)
353{
354 QPainter painter(this);
356 if (isEnabled())
357 state = isDown() ? QIcon::Active : QIcon::Normal;
358 const QLineEditPrivate *lep = lineEditPrivate();
359 const int iconWidth = lep ? lep->sideWidgetParameters().iconSize : 16;
360 const QSize iconSize(iconWidth, iconWidth);
361 const QPixmap iconPixmap = icon().pixmap(iconSize, devicePixelRatio(), state, QIcon::Off);
362 QRect pixmapRect = QRect(QPoint(0, 0), iconSize);
363 pixmapRect.moveCenter(rect().center());
364 painter.setOpacity(m_opacity);
365 painter.drawPixmap(pixmapRect, iconPixmap);
366}
367
368void QLineEditIconButton::actionEvent(QActionEvent *e)
369{
370 switch (e->type()) {
372 const auto *action = e->action();
373 if (isVisibleTo(parentWidget()) != action->isVisible()) {
374 setVisible(action->isVisible());
375 if (QLineEditPrivate *lep = lineEditPrivate())
376 lep->positionSideWidgets();
377 }
378 }
379 break;
380 default:
381 break;
382 }
384}
385
386void QLineEditIconButton::setOpacity(qreal value)
387{
388 if (!qFuzzyCompare(m_opacity, value)) {
389 m_opacity = value;
390 updateCursor();
391 update();
392 }
393}
394
395#if QT_CONFIG(animation)
396bool QLineEditIconButton::shouldHideWithText() const
397{
398 return m_hideWithText;
399}
400
401void QLineEditIconButton::setHideWithText(bool hide)
402{
403 m_hideWithText = hide;
404}
405
406void QLineEditIconButton::onAnimationFinished()
407{
408 if (shouldHideWithText() && isVisible() && m_fadingOut) {
409 hide();
410 m_fadingOut = false;
411
412 // Invalidate previous geometry to take into account new size of side widgets
413 if (auto le = lineEditPrivate())
414 le->updateGeometry_helper(true);
415 }
416}
417
418void QLineEditIconButton::animateShow(bool visible)
419{
420 m_fadingOut = !visible;
421
422 if (shouldHideWithText() && !isVisible()) {
423 show();
424
425 // Invalidate previous geometry to take into account new size of side widgets
426 if (auto le = lineEditPrivate())
427 le->updateGeometry_helper(true);
428 }
429
430 startOpacityAnimation(visible ? 1.0 : 0.0);
431}
432
433void QLineEditIconButton::startOpacityAnimation(qreal endValue)
434{
436 connect(animation, &QPropertyAnimation::finished, this, &QLineEditIconButton::onAnimationFinished);
437
439 animation->setEndValue(endValue);
441}
442#endif
443
444void QLineEditIconButton::updateCursor()
445{
446#ifndef QT_NO_CURSOR
447 setCursor(qFuzzyCompare(m_opacity, qreal(1.0)) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor());
448#endif
449}
450#endif // QT_CONFIG(toolbutton)
451
452#if QT_CONFIG(animation) && QT_CONFIG(toolbutton)
453static void displayWidgets(const QLineEditPrivate::SideWidgetEntryList &widgets, bool display)
454{
455 for (const auto &e : widgets) {
457 static_cast<QLineEditIconButton *>(e.widget)->animateShow(display);
458 }
459}
460#endif
461
463{
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);
472#endif
473 }
474 }
475}
476
478{
479 Q_Q(QLineEdit);
480 if (!q->text().isEmpty()) {
481 q->clear();
482 textEdited(QString());
483 }
484}
485
487{
488 Q_Q(QLineEdit);
489 edited = false;
490 emit q->returnPressed();
491 emit q->editingFinished();
492}
493
495{
496 Q_Q(const QLineEdit);
498 result.iconSize = q->style()->pixelMetric(QStyle::PM_LineEditIconSize, nullptr, q);
499 result.margin = q->style()->pixelMetric(QStyle::PM_LineEditIconMargin, nullptr, q);
500 result.widgetWidth = result.iconSize + 6;
501 result.widgetHeight = result.iconSize + 2;
502 return result;
503}
504
506{
507 Q_Q(const QLineEdit);
508 QStyleOptionFrame styleOption;
509 q->initStyleOption(&styleOption);
510 return q->style()->standardIcon(QStyle::SP_LineEditClearButton, &styleOption, q);
511}
512
514{
515#if QT_CONFIG(action)
516 for (const SideWidgetEntry &e : trailingSideWidgets) {
517 if (e.flags & SideWidgetClearButton) {
518 e.action->setEnabled(enabled);
519 break;
520 }
521 }
522#else
524#endif
525}
526
528{
529 Q_Q(QLineEdit);
530 if (hasSideWidgets()) {
531 const QRect contentRect = q->rect();
532 const SideWidgetParameters p = sideWidgetParameters();
533 const int delta = p.margin + p.widgetWidth;
534 QRect widgetGeometry(QPoint(p.margin, (contentRect.height() - p.widgetHeight) / 2),
535 QSize(p.widgetWidth, p.widgetHeight));
536 for (const SideWidgetEntry &e : leftSideWidgetList()) {
537 e.widget->setGeometry(widgetGeometry);
538#if QT_CONFIG(action)
539 if (e.action->isVisible())
540 widgetGeometry.moveLeft(widgetGeometry.left() + delta);
541#else
542 Q_UNUSED(delta);
543#endif
544 }
545 widgetGeometry.moveLeft(contentRect.width() - p.widgetWidth - p.margin);
546 for (const SideWidgetEntry &e : rightSideWidgetList()) {
547 e.widget->setGeometry(widgetGeometry);
548#if QT_CONFIG(action)
549 if (e.action->isVisible())
550 widgetGeometry.moveLeft(widgetGeometry.left() - delta);
551#endif
552 }
553 }
554}
555
556#if QT_CONFIG(action)
557QLineEditPrivate::SideWidgetLocation QLineEditPrivate::findSideWidget(const QAction *a) const
558{
559 int i = 0;
560 for (const auto &e : leadingSideWidgets) {
561 if (a == e.action)
563 ++i;
564 }
565 i = 0;
566 for (const auto &e : trailingSideWidgets) {
567 if (a == e.action)
569 ++i;
570 }
571 return {QLineEdit::LeadingPosition, -1};
572}
573
574QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition position, int flags)
575{
576 Q_Q(QLineEdit);
577 if (!newAction)
578 return nullptr;
579 if (!hasSideWidgets()) { // initial setup.
582 lastTextSize = q->text().size();
583 }
584 QWidget *w = nullptr;
585 // Store flags about QWidgetAction here since removeAction() may be called from ~QAction,
586 // in which a qobject_cast<> no longer works.
587 if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(newAction)) {
588 if ((w = widgetAction->requestWidget(q)))
589 flags |= SideWidgetCreatedByWidgetAction;
590 }
591 if (!w) {
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) {
599
600#if QT_CONFIG(animation)
601 // The clear button is handled only by this widget. The button should be really
602 // shown/hidden in order to calculate size hints correctly.
603 toolButton->setHideWithText(true);
604#endif
605 }
606 toolButton->setDefaultAction(newAction);
607 w = toolButton;
608#else
609 return nullptr;
610#endif
611 }
612
613 // QTBUG-59957: clear button should be the leftmost action.
614 if (!before && !(flags & SideWidgetClearButton) && position == QLineEdit::TrailingPosition) {
615 for (const SideWidgetEntry &e : trailingSideWidgets) {
616 if (e.flags & SideWidgetClearButton) {
617 before = e.action;
618 break;
619 }
620 }
621 }
622
623 // If there is a 'before' action, it takes preference
624
625 // There's a bug in GHS compiler that causes internal error on the following code.
626 // The affected GHS compiler versions are 2016.5.4 and 2017.1. GHS internal reference
627 // to track the progress of this issue is TOOLS-26637.
628 // This temporary workaround allows to compile with GHS toolchain and should be
629 // removed when GHS provides a patch to fix the compiler issue.
630
631#if defined(Q_CC_GHS)
632 const SideWidgetLocation loc = {position, -1};
633 const auto location = before ? findSideWidget(before) : loc;
634#else
635 const auto location = before ? findSideWidget(before) : SideWidgetLocation{position, -1};
636#endif
637
638 SideWidgetEntryList &list = location.position == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets;
639 list.insert(location.isValid() ? list.begin() + location.index : list.end(),
640 SideWidgetEntry(w, newAction, flags));
641 positionSideWidgets();
642 w->show();
643 return w;
644}
645
646void QLineEditPrivate::removeAction(QAction *action)
647{
648 Q_Q(QLineEdit);
649 const auto location = findSideWidget(action);
650 if (!location.isValid())
651 return;
652 SideWidgetEntryList &list = location.position == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets;
653 SideWidgetEntry entry = list[location.index];
654 list.erase(list.begin() + location.index);
655 if (entry.flags & SideWidgetCreatedByWidgetAction)
656 static_cast<QWidgetAction *>(entry.action)->releaseWidget(entry.widget);
657 else
658 delete entry.widget;
659 positionSideWidgets();
660 if (!hasSideWidgets()) // Last widget, remove connection
663 q->update();
664}
665#endif // QT_CONFIG(action)
666
669{
670 if (widgets.empty())
671 return defaultMargin;
672
673 const auto visibleSideWidgetCount = std::count_if(widgets.begin(), widgets.end(),
675#if QT_CONFIG(toolbutton) && QT_CONFIG(animation)
676 // a button that's fading out doesn't get any space
677 if (auto* iconButton = qobject_cast<QLineEditIconButton*>(e.widget))
678 return iconButton->needsSpace();
679
680#endif
681 return e.widget->isVisibleTo(e.widget->parentWidget());
682 });
683
684 return defaultMargin + (parameters.margin + parameters.widgetWidth) * visibleSideWidgetCount;
685}
686
688{
689 return {effectiveTextMargin(textMargins.left(), leftSideWidgetList(), sideWidgetParameters()),
690 textMargins.top(),
691 effectiveTextMargin(textMargins.right(), rightSideWidgetList(), sideWidgetParameters()),
692 textMargins.bottom()};
693}
694
695
697
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.
void clicked(bool checked=false)
This signal is emitted when the button is activated (i.e., pressed down then released while the mouse...
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
void highlighted(const QString &text)
This signal is sent when an item in the popup() is highlighted by the user.
@ InlineCompletion
Definition qcompleter.h:40
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.
Definition qcursor.h:45
\inmodule QtGui
Definition qdrag.h:22
Qt::DropAction exec(Qt::DropActions supportedActions=Qt::MoveAction)
Definition qdrag.cpp:201
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
Definition qdrag.cpp:101
QObject * target() const
Returns the target of the drag and drop operation.
Definition qdrag.cpp:178
@ ActionChanged
Definition qcoreevent.h:151
@ MouseButtonRelease
Definition qcoreevent.h:61
Type type() const
Returns the event type.
Definition qcoreevent.h:304
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:834
void handleWindowActivate()
QRect adjustedControlRect(const QRect &) const
void textChanged(const QString &)
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 updatePasswordEchoEditing(bool)
QIcon clearButtonIcon() const
bool shouldEnableInputMethod() const
QMargins effectiveTextMargins() const
void controlEditingFinished()
void cursorPositionChanged(int, int)
QRect adjustedContentsRect() const
void updateNeeded(const QRect &)
QRect cursorRect() const
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.
Definition qlineedit.h:28
void inputRejected()
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
void textChanged(const QString &)
This signal is emitted whenever the text changes.
void setText(const QString &)
iterator erase(const_iterator begin, const_iterator end)
Definition qlist.h:889
iterator insert(qsizetype i, parameter_type t)
Definition qlist.h:488
bool empty() const noexcept
Definition qlist.h:685
iterator end()
Definition qlist.h:626
iterator begin()
Definition qlist.h:625
\inmodule QtCore
Definition qmargins.h:24
\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:196
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)
Definition qobject_p.h:299
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
Definition qobject_p.h:328
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2195
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
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
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition qpoint.h:404
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
Definition qrect.h:167
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr QRect marginsRemoved(const QMargins &margins) const noexcept
Removes the margins from the rectangle, shrinking it.
Definition qrect.h:454
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:185
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Definition qevent.h:119
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:78
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
Definition qstring.h:129
QString left(qsizetype n) const &
Definition qstring.h:363
QString mid(qsizetype position, qsizetype n=-1) const &
Definition qstring.cpp:5300
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
\variable QStyleOptionFocusRect::backgroundColor
@ SH_LineEdit_PasswordMaskDelay
Definition qstyle.h:690
@ SH_LineEdit_PasswordCharacter
Definition qstyle.h:620
@ SH_BlinkCursorWhenTextSelected
Definition qstyle.h:613
@ SP_LineEditClearButton
Definition qstyle.h:787
@ PM_LineEditIconMargin
Definition qstyle.h:537
@ PM_LineEditIconSize
Definition qstyle.h:536
@ 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
void displayTextChanged(const QString &)
void textChanged(const QString &)
void textEdited(const QString &)
bool inSelection(int x) const
void cursorPositionChanged(int, int)
QString selectedText() const
void updateNeeded(const QRect &)
void setPasswordMaskDelay(int delay)
QString preeditAreaText() const
void setPasswordCharacter(QChar character)
Qt::InputMethodHints imHints
Definition qwidget_p.h:664
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void update()
Updates the widget unless updates are disabled or the widget is hidden.
QString text
QCursor cursor
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:300
@ WA_MacShowFocusRect
Definition qnamespace.h:359
@ WA_InputMethodEnabled
Definition qnamespace.h:295
@ NoFocus
Definition qnamespace.h:107
@ StrongFocus
Definition qnamespace.h:110
@ 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:333
static int effectiveTextMargin(int defaultMargin, const QLineEditPrivate::SideWidgetEntryList &widgets, const QLineEditPrivate::SideWidgetParameters &parameters)
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
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLbitfield flags
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:187
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]