8#include <private/qqmlglobal_p.h>
9#include <private/qv4scopedvalue_p.h>
11#include <QtCore/qcoreapplication.h>
12#include <QtCore/qmimedata.h>
13#include <QtQml/qqmlinfo.h>
14#include <QtGui/qevent.h>
15#include <QTextBoundaryFinder>
17#include <QtQuick/qsgsimplerectnode.h>
19#include <QtGui/qstylehints.h>
20#include <QtGui/qinputmethod.h>
21#include <QtCore/qmath.h>
23#if QT_CONFIG(accessibility)
28#include <QtGui/private/qtextengine_p.h>
29#include <QtGui/private/qinputcontrol_p.h>
83 updateCursorRectangle();
106 QString res =
d->m_maskData ?
d->stripString(content) : content;
114 invalidateFontCaches();
126 d->internalSetText(
s, -1,
false);
158 return d->renderType;
189 return d->m_text.size();
416 return d->sourceFont;
422 if (
d->sourceFont ==
font)
425 d->sourceFont =
font;
428 if (
d->font.pointSizeF() != -1) {
431 d->font.setPointSizeF(
size/2.0);
433 if (oldFont !=
d->font) {
435 updateCursorRectangle();
459 d->textLayoutDirty =
true;
476 return d->selectionColor;
482 if (
d->selectionColor ==
color)
485 d->selectionColor =
color;
486 if (
d->hasSelectedText()) {
487 d->textLayoutDirty =
true;
502 return d->selectedTextColor;
508 if (
d->selectedTextColor ==
color)
511 d->selectedTextColor =
color;
512 if (
d->hasSelectedText()) {
513 d->textLayoutDirty =
true;
568 updateCursorRectangle();
575 d->hAlignImplicit =
true;
578 updateCursorRectangle();
586 if (!
d->hAlignImplicit &&
d->effectiveLayoutMirror) {
598 return effectiveAlignment;
607 if (
hAlign == align && !forceAlign)
611 const auto oldEffectiveHAlign =
q->effectiveHAlign();
616 emit q->horizontalAlignmentChanged(align);
619 if (
q->effectiveHAlign() != oldEffectiveHAlign) {
620 emit q->effectiveHorizontalAlignmentChanged();
624 if (forceAlign && wasImplicit) {
627 emit q->effectiveHorizontalAlignmentChanged();
641 while (!character->isNull()) {
642 switch (character->direction()) {
701 updateCursorRectangle();
702 d->updateBaselineOffset();
735 if (
mode ==
d->wrapMode)
739 updateCursorRectangle();
746 if (
q->isComponentComplete()) {
748 q->updateCursorRectangle();
749 emit q->effectiveHorizontalAlignmentChanged();
766 return d->m_readOnly;
772 if (
d->m_readOnly == ro)
776 setFlag(QQuickItem::ItemAcceptsInputMethod, !ro);
779 d->setCursorPosition(
d->end());
784 d->emitUndoRedoChanged();
805 return d->m_maxLength;
811 if (
d->m_maxLength == ml ||
d->m_maskData)
815 d->internalSetText(
d->m_text, -1,
false);
849 return d->cursorVisible;
855 if (
d->cursorVisible == on)
857 d->cursorVisible = on;
861 d->updateCursorBlinking();
912 c +=
d->m_preeditCursor;
916 QTextLine l =
d->m_textLayout.lineForTextPosition(
c);
922 if (
d->overwriteMode) {
945 return d->lastSelectionStart;
961 return d->lastSelectionEnd;
979 if (
start < 0 || end < 0 || start >
d->m_text.size() ||
end >
d->m_text.size())
1002 return d->selectedText();
1014 return d->focusOnPress;
1020 if (
d->focusOnPress ==
b)
1023 d->focusOnPress =
b;
1038 return d->autoScroll;
1044 if (
d->autoScroll ==
b)
1049 updateCursorRectangle();
1053#if QT_CONFIG(validator)
1078QValidator* QQuickTextInput::validator()
const
1081 return d->m_validator;
1087 if (
d->m_validator ==
v)
1090 if (
d->m_validator) {
1098 if (
d->m_validator) {
1107 emit validatorChanged();
1110void QQuickTextInput::q_validatorChanged()
1134 a += m_preeditCursor;
1148void QQuickTextInputPrivate::checkIsValid()
1152 ValidatorState
state = hasAcceptableInput(
m_text);
1155 if (
state != AcceptableInput) {
1158 emit q->acceptableInputChanged();
1162 emit q->acceptableInputChanged();
1178 return d->inputMask();
1184 QString canonicalInputMask = im;
1187 if (
d->inputMask() == canonicalInputMask)
1190 d->setInputMask(im);
1206 return d->m_acceptableInput;
1239Qt::InputMethodHints QQuickTextInputPrivate::effectiveInputMethodHints()
const
1241 Qt::InputMethodHints hints = inputMethodHints;
1245 hints &=
~Qt::ImhHiddenText;
1275 d->cancelPasswordEchoTimer();
1276 d->m_echoMode = echo;
1277 d->m_passwordEchoEditing =
false;
1281 d->updateDisplayText();
1282 updateCursorRectangle();
1288 d->m_text.reserve(30);
1336 return d->inputMethodHints;
1347 if (hints ==
d->inputMethodHints)
1350 d->inputMethodHints = hints;
1372 return d->cursorComponent;
1381void QQuickTextInput::createCursor()
1384 d->cursorPending =
true;
1403 else if (
pos >
d->m_cursor)
1404 pos +=
d->preeditAreaText().size();
1412 if (
d->overwriteMode) {
1458 x =
arg->toNumber();
1460 if (++i < args->
length()) {
1462 y =
arg->toNumber();
1465 if (++i < args->
length()) {
1471 const int cursor =
d->m_cursor;
1474 const int preeditLength =
d->preeditAreaText().size();
1476 ?
pos - preeditLength
1494 if (
y < (
line.rect().bottom() + nextLine.y()) / 2)
1519 return d->overwriteMode;
1525 if (
d->overwriteMode == overwrite)
1527 d->overwriteMode = overwrite;
1548 d->processKeyEvent(ev);
1550 if (!ev->isAccepted())
1558 const bool wasComposing =
d->hasImState;
1559 d->processInputMethodEvent(ev);
1560 if (!ev->isAccepted())
1561 QQuickImplicitSizeItem::inputMethodEvent(ev);
1563 if (wasComposing !=
d->hasImState)
1579 event->setAccepted(
true);
1580 if (!
d->hasPendingTripleClick()) {
1581 d->tripleClickStartPoint =
event->position();
1582 d->tripleClickTimer.start();
1585 if (
d->sendMouseEventToInputContext(
event))
1595 d->pressPos =
event->position();
1597 if (
d->sendMouseEventToInputContext(
event))
1601 if (
d->selectByMouse &&
1604 ||
d->selectByTouchDrag
1608 d->selectPressed =
true;
1609 QPointF distanceVector =
d->pressPos -
d->tripleClickStartPoint;
1610 if (
d->hasPendingTripleClick()
1612 event->setAccepted(
true);
1620 ||
d->selectByTouchDrag
1628 if (
d->focusOnPress && !
qGuiApp->styleHints()->setFocusOnTouchRelease())
1631 event->setAccepted(
true);
1639 && !
d->selectByTouchDrag
1644 if (
d->selectPressed) {
1649 if (
d->composeMode()) {
1651 int startPos =
d->positionAt(
d->pressPos);
1652 int currentPos =
d->positionAt(
event->position());
1653 if (startPos != currentPos)
1654 d->setSelection(startPos, currentPos - startPos);
1660 event->setAccepted(
true);
1669 if (
d->sendMouseEventToInputContext(
event))
1671 if (
d->selectPressed) {
1672 d->selectPressed =
false;
1676#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
1677 ||
d->selectByTouchDrag
1681#if QT_CONFIG(clipboard)
1695 if (!isMouse && !
d->hasSelectedText())
1696 d->moveCursor(
d->positionAt(
event->position()),
false);
1698 if (
d->focusOnPress &&
qGuiApp->styleHints()->setFocusOnTouchRelease())
1701 if (!
event->isAccepted())
1708 if (composeMode()) {
1710 int mousePos = tmp_cursor -
m_cursor;
1728 d->selectPressed =
false;
1734#if QT_CONFIG(shortcut)
1737 if (
d->m_readOnly) {
1769 switch (ke->key()) {
1791 const QRectF &oldGeometry)
1795 if (newGeometry.
width() != oldGeometry.
width())
1798 d->updateBaselineOffset();
1799 updateCursorRectangle();
1828 const qreal width = qMax<qreal>(0,
q->width() -
q->leftPadding() -
q->rightPadding());
1830 qreal widthUsed = 0;
1833 const qreal cursorWidth = cix >= 0 ? cix :
width - cix;
1838 if (widthUsed <=
width) {
1858 if (preeditLength > 0) {
1867 if (previousScroll !=
hscroll)
1891 const qreal height = qMax<qreal>(0,
q->height() -
q->topPadding() -
q->bottomPadding());
1921 if (preeditLength > 0) {
1931 if (previousScroll !=
vscroll)
1935void QQuickTextInput::triggerPreprocess()
1946 invalidateFontCaches();
1949void QQuickTextInput::invalidateFontCaches()
1953 if (
d->m_textLayout.engine() !=
nullptr)
1954 d->m_textLayout.engine()->resetFontEngineCache();
1965 qGuiApp->inputMethod()->show();
1985 if (node ==
nullptr)
1986 node =
d->sceneGraphContext()->createInternalTextNode(
d->sceneGraphRenderContext());
1989 const bool showCursor = !
isReadOnly() &&
d->cursorItem ==
nullptr &&
d->cursorVisible &&
d->m_blinkStatus;
1991 if (!
d->textLayoutDirty && oldNode !=
nullptr) {
2012 if (
d->autoScroll &&
d->m_textLayout.lineCount() > 0) {
2015 offset += -
QPointF(
d->hscroll,
d->vscroll +
d->m_textLayout.lineAt(0).ascent() - fm.ascent());
2020 if (!
d->m_textLayout.text().isEmpty()
2022 || !
d->m_textLayout.preeditAreaText().isEmpty()
2026 d->selectionStart(),
2027 d->selectionEnd() - 1);
2034 d->textLayoutDirty =
false;
2037 invalidateFontCaches();
2050 if (!
d->extra.isAllocated()
2051 ||
d->extra->enterKeyAttached ==
nullptr
2056 while (
next &&
next !=
this && !
next->activeFocusOnTab()) {
2057 next =
next->nextItemInFocusChain();
2058 if (
next == originalNext) {
2064 const auto nextYPos =
next->mapToGlobal(
QPoint(0, 0)).
y();
2065 const auto currentYPos = this->mapToGlobal(
QPoint(0, 0)).y();
2066 if (currentYPos < nextYPos)
2084 return QVariant((
int)
d->effectiveInputMethodHints());
2088 return d->anchorRectangle();
2108 if (
d->selectionStart() ==
d->selectionEnd())
2110 else if (
d->selectionStart() ==
d->m_cursor)
2123 return QVariant(
d->m_text.left(
d->m_cursor));
2127 return QQuickItem::inputMethodQuery(
property);
2163 qmlWarning(
this) <<
"isRightToLeft(start, end) called with the end property being smaller than the start.";
2170#if QT_CONFIG(clipboard)
2180void QQuickTextInput::cut()
2198void QQuickTextInput::copy()
2209void QQuickTextInput::paste()
2228 if (!
d->m_readOnly) {
2231 d->finishChange(-1,
true);
2244 if (!
d->m_readOnly) {
2261 if (
d->m_passwordMaskDelay > 0)
2262 d->m_passwordEchoTimer.start(
d->m_passwordMaskDelay,
this);
2264 if (position < 0 || position >
d->m_text.size())
2267 const int priorState =
d->m_undoState;
2271 if (
d->hasSelectedText()) {
2275 if (
d->m_maskData) {
2276 insertText =
d->maskString(
position, insertText);
2277 for (
int i = 0;
i < insertText.
size(); ++
i) {
2285 d->m_textDirty =
true;
2286 if (position < d->m_selend &&
position + insertText.
size() >
d->m_selstart)
2287 d->m_selDirty =
true;
2289 int remaining =
d->m_maxLength -
d->m_text.size();
2290 if (remaining != 0) {
2291 insertText = insertText.
left(remaining);
2293 for (
int i = 0;
i < insertText.
size(); ++
i)
2297 d->m_cursor += insertText.
size();
2299 d->m_selstart += insertText.
size();
2301 d->m_selend += insertText.
size();
2302 d->m_textDirty =
true;
2303 if (
position >=
d->m_selstart && position <= d->m_selend)
2304 d->m_selDirty =
true;
2310 d->finishChange(priorState);
2312 if (
d->lastSelectionStart !=
d->lastSelectionEnd) {
2313 if (
d->m_selstart !=
d->lastSelectionStart) {
2314 d->lastSelectionStart =
d->m_selstart;
2317 if (
d->m_selend !=
d->lastSelectionEnd) {
2318 d->lastSelectionEnd =
d->m_selend;
2342 if (start < d->m_selend &&
end >
d->m_selstart)
2343 d->m_selDirty =
true;
2345 const int priorState =
d->m_undoState;
2350 if (start <= d->m_cursor &&
d->m_cursor <
end) {
2353 for (
int i =
d->m_cursor;
i >=
start; --
i) {
2357 for (
int i =
end - 1;
i >
d->m_cursor; --
i) {
2367 if (
d->m_maskData) {
2378 if (
d->m_selstart >
start)
2380 if (
d->m_selend >=
end)
2386 d->m_textDirty =
true;
2387 d->finishChange(priorState);
2389 if (
d->lastSelectionStart !=
d->lastSelectionEnd) {
2390 if (
d->m_selstart !=
d->lastSelectionStart) {
2391 d->lastSelectionStart =
d->m_selstart;
2394 if (
d->m_selend !=
d->lastSelectionEnd) {
2395 d->lastSelectionEnd =
d->m_selend;
2410 d->selectWordAtPos(
d->m_cursor);
2427 return QString(
d->m_passwordCharacter);
2437 d->updateDisplayText();
2452 return d->m_passwordMaskDelay;
2458 if (
d->m_passwordMaskDelay != delay) {
2459 d->m_passwordMaskDelay = delay;
2460 emit passwordMaskDelayChanged(delay);
2488 return d->m_textLayout.text().insert(
d->m_textLayout.preeditAreaPosition(),
d->m_textLayout.preeditAreaText());
2506 return d->m_textLayout.preeditAreaText();
2530 return d->selectByMouse;
2536 if (
d->selectByMouse != on) {
2537 d->selectByMouse = on;
2556 return d->mouseSelectionMode;
2562 if (
d->mouseSelectionMode !=
mode) {
2563 d->mouseSelectionMode =
mode;
2578 return d->persistentSelection;
2584 if (
d->persistentSelection == on)
2586 d->persistentSelection = on;
2599#if QT_CONFIG(clipboard)
2601 if (!
d->canPasteValid) {
2651 return d->contentSize.width();
2665 return d->contentSize.height();
2715 d->moveCursor(
pos,
true);
2716 }
else if (
pos !=
d->m_cursor) {
2717 const int cursor =
d->m_cursor;
2719 if (!
d->hasSelectedText())
2720 anchor =
d->m_cursor;
2721 else if (
d->selectionStart() ==
d->m_cursor)
2722 anchor =
d->selectionEnd();
2724 anchor =
d->selectionStart();
2729 finder.setPosition(anchor);
2731 const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons();
2734 finder.toPreviousBoundary();
2736 anchor = finder.position() != -1 ? finder.position() : 0;
2738 finder.setPosition(
pos);
2739 if (
pos > 0 && !finder.boundaryReasons())
2740 finder.toNextBoundary();
2741 const int cursor = finder.position() != -1 ? finder.position() :
text.
size();
2743 d->setSelection(anchor,
cursor - anchor);
2747 finder.setPosition(anchor);
2749 const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons();
2752 finder.toNextBoundary();
2754 anchor = finder.position() != -1 ? finder.position() :
text.
size();
2756 finder.setPosition(
pos);
2757 if (
pos <
text.
size() && !finder.boundaryReasons())
2758 finder.toPreviousBoundary();
2759 const int cursor = finder.position() != -1 ? finder.position() : 0;
2761 d->setSelection(anchor,
cursor - anchor);
2769 d->handleFocusEvent(
event);
2776 bool focus =
event->gotFocus();
2778 q->setCursorVisible(
focus);
2782 q->q_updateAlignment();
2785 qGuiApp->inputMethod()->show();
2787 q,
SLOT(q_updateAlignment()));
2800 if (hasAcceptableInput(
m_text) == AcceptableInput ||
fixup())
2801 emit q->editingFinished();
2805 q,
SLOT(q_updateAlignment()));
2813 d->handleFocusEvent(
event);
2835 return d->hasImState;
2845 , explicitTopPadding(
false)
2846 , explicitLeftPadding(
false)
2847 , explicitRightPadding(
false)
2848 , explicitBottomPadding(
false)
2849 , implicitResize(true)
2856#if QT_CONFIG(clipboard)
2864 q->setFlag(QQuickItem::ItemAcceptsInputMethod);
2867#if QT_CONFIG(clipboard)
2876 if (!qmlDisableDistanceField()) {
2895void QQuickTextInput::updateCursorRectangle(
bool scroll)
2898 if (!isComponentComplete())
2902 d->updateHorizontalScroll();
2903 d->updateVerticalScroll();
2908 emit cursorRectangleChanged();
2909 if (
d->cursorItem) {
2911 d->cursorItem->setPosition(
r.topLeft());
2912 d->cursorItem->setHeight(
r.height());
2919void QQuickTextInput::selectionChanged()
2922 d->textLayoutDirty =
true;
2926 emit selectedTextChanged();
2928 if (
d->lastSelectionStart !=
d->selectionStart()) {
2929 d->lastSelectionStart =
d->selectionStart();
2930 if (
d->lastSelectionStart == -1)
2931 d->lastSelectionStart =
d->m_cursor;
2932 emit selectionStartChanged();
2934 if (
d->lastSelectionEnd !=
d->selectionEnd()) {
2935 d->lastSelectionEnd =
d->selectionEnd();
2936 if (
d->lastSelectionEnd == -1)
2937 d->lastSelectionEnd =
d->m_cursor;
2938 emit selectionEndChanged();
2946 int cursorWidth =
d->cursorItem ? 0 : 1;
2949 if (!
d->autoScroll ||
d->contentSize.width() <
width())
2953 QRectF r(-
hscroll, -
d->vscroll,
d->contentSize.width(),
d->contentSize.height());
2954 r.setRight(
r.right() + cursorWidth);
2962 int cursorWidth =
d->cursorItem ?
d->cursorItem->width() : 1;
2966 r.setRight(
r.right() + cursorWidth);
2970void QQuickTextInput::q_canPasteChanged()
2973 bool old =
d->canPaste;
2974#if QT_CONFIG(clipboard)
2978 d->canPaste =
false;
2981 bool changed =
d->canPaste != old || !
d->canPasteValid;
2982 d->canPasteValid =
true;
2984 emit canPasteChanged();
2988void QQuickTextInput::q_updateAlignment()
2991 if (
d->determineHorizontalAlignment()) {
2993 updateCursorRectangle();
3003void QQuickTextInputPrivate::updateDisplayText(
bool forceUpdate)
3018 if (
cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) {
3022 if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00)
3035 if (uc[
i] == QChar::LineSeparator
3036 || uc[
i] == QChar::ParagraphSeparator
3037 || uc[
i] == QChar::ObjectReplacementCharacter)
3044 emit q_func()->displayTextChanged();
3057 option.setAlignment(Qt::Alignment(
q->effectiveHAlign()));
3066 line.setLineWidth(INT_MAX);
3067 const qreal theImplicitWidth =
qCeil(
line.naturalTextWidth()) +
q->leftPadding() +
q->rightPadding();
3070 return theImplicitWidth;
3080 if (
q->isComponentComplete())
3089 qreal oldPadding =
q->topPadding();
3096 q->updateCursorRectangle();
3097 emit q->topPaddingChanged();
3104 qreal oldPadding =
q->leftPadding();
3111 q->updateCursorRectangle();
3112 emit q->leftPaddingChanged();
3119 qreal oldPadding =
q->rightPadding();
3126 q->updateCursorRectangle();
3127 emit q->rightPaddingChanged();
3134 qreal oldPadding =
q->bottomPadding();
3137 extra.value().explicitBottomPadding = !
reset;
3141 q->updateCursorRectangle();
3142 emit q->bottomPaddingChanged();
3148 return !
extra.isAllocated() ||
extra->implicitResize;
3154 extra.value().implicitResize =
false;
3155 else if (
extra.isAllocated())
3156 extra->implicitResize =
true;
3163 if (!
q->isComponentComplete())
3170 option.setAlignment(Qt::Alignment(
q->effectiveHAlign()));
3171 if (!qmlDisableDistanceField())
3181 line.setLineWidth(INT_MAX);
3185 q->setImplicitWidth(
qCeil(
line.naturalTextWidth()) +
q->leftPadding() +
q->rightPadding());
3194 line.setLineWidth(lineWidth);
3201 }
while (
line.isValid());
3218 q->setImplicitSize(
width +
q->leftPadding() +
q->rightPadding(),
height +
q->topPadding() +
q->bottomPadding());
3220 q->setImplicitHeight(
height +
q->topPadding() +
q->bottomPadding());
3226 emit q->contentSizeChanged();
3238 if (!
q->isComponentComplete())
3242 if (
q->heightValid()) {
3245 yoff = surplusHeight;
3247 yoff = surplusHeight/2;
3249 q->setBaselineOffset(fm.ascent() + yoff +
q->topPadding());
3252#if QT_CONFIG(clipboard)
3295void QQuickTextInputPrivate::commitPreedit()
3311void QQuickTextInputPrivate::cancelPreedit()
3337 if (separateSelection()) {
3338 removeSelectedText();
3344 if (
m_cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) {
3348 if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00) {
3349 internalDelete(
true);
3353 internalDelete(
true);
3355 finishChange(priorState);
3370 if (separateSelection()) {
3371 removeSelectedText();
3377 finishChange(priorState);
3390 if (separateSelection())
3391 removeSelectedText();
3392 internalInsert(newText);
3393 finishChange(priorState);
3404 separateSelection();
3407 removeSelectedText();
3409 finishChange(priorState,
false,
false);
3428 qWarning(
"QQuickTextInputPrivate::setSelection: Invalid start position");
3450 emitCursorPositionChanged();
3453 emit q->selectionChanged();
3454 emitCursorPositionChanged();
3473 updateDisplayText();
3485#if QT_CONFIG(validator)
3489 m_validator->fixup(textCopy);
3492 internalSetText(textCopy, cursorCopy);
3534 emit q->selectionChanged();
3536 emitCursorPositionChanged();
3538 q->updateInputMethod();
3553 int priorState = -1;
3554 bool isGettingInput = !
event->commitString().isEmpty()
3555 ||
event->preeditString() != preeditAreaText()
3556 ||
event->replacementLength() > 0;
3557 bool cursorPositionChanged =
false;
3558 bool selectionChange =
false;
3559 m_preeditDirty =
event->preeditString() != preeditAreaText();
3561 if (isGettingInput) {
3564 separateSelection();
3570 removeSelectedText();
3574 if (
event->replacementStart() <= 0)
3575 c +=
event->commitString().size() -
qMin(-
event->replacementStart(),
event->replacementLength());
3577 int cursorInsertPos =
m_cursor +
event->replacementStart();
3578 if (cursorInsertPos < 0)
3579 cursorInsertPos = 0;
3582 if (
event->replacementLength()) {
3586 removeSelectedText();
3590 if (!
event->commitString().isEmpty()) {
3591 internalInsert(
event->commitString());
3592 cursorPositionChanged =
true;
3597 for (
int i = 0;
i <
event->attributes().
size(); ++
i) {
3604 if (!cursorPositionChanged)
3612 selectionChange =
true;
3617 cursorPositionChanged =
true;
3623 emit q->preeditTextChanged();
3624 if (!
event->preeditString().isEmpty() && m_undoPreeditState == -1)
3626 m_undoPreeditState = priorState;
3628 const int oldPreeditCursor = m_preeditCursor;
3629 m_preeditCursor =
event->preeditString().size();
3630 hasImState = !
event->preeditString().isEmpty();
3632 QVector<QTextLayout::FormatRange>
formats;
3633 for (
int i = 0;
i <
event->attributes().
size(); ++
i) {
3637 m_preeditCursor =
a.
start;
3645 o.length =
a.length;
3653 updateDisplayText(
true);
3654 if (cursorPositionChanged && emitCursorPositionChanged())
3656 else if (m_preeditCursor != oldPreeditCursor || isGettingInput)
3657 q->updateCursorRectangle();
3660 finishChange(priorState);
3664 if (selectionChange) {
3665 emit q->selectionChanged();
3671 if (
event->preeditString().isEmpty())
3672 m_undoPreeditState = -1;
3710bool QQuickTextInputPrivate::finishChange(
int validateFromState,
bool update,
bool edited)
3718 bool alignmentChanged =
false;
3727#if QT_CONFIG(validator)
3731 textCopy = maskString(0,
m_text,
true);
3739 if (
m_text != textCopy) {
3740 internalSetText(textCopy, cursorCopy);
3753 if (m_undoPreeditState >= 0 && (m_undoPreeditState < validateFromState || validateFromState < 0))
3754 validateFromState = m_undoPreeditState;
3756 if (validateFromState >= 0 && wasValidInput && !
m_validInput) {
3759 internalUndo(validateFromState);
3770 m_preeditDirty =
false;
3774 emit q->textEdited();
3775 emit q->textChanged();
3778 updateDisplayText(alignmentChanged);
3781 emit q->acceptableInputChanged();
3784 if (m_preeditDirty) {
3785 m_preeditDirty =
false;
3787 alignmentChanged =
true;
3795 emit q->selectionChanged();
3800 if (inputMethodAttributesChanged)
3801 q->updateInputMethod();
3803 emitUndoRedoChanged();
3805 if (!emitCursorPositionChanged() && (alignmentChanged ||
textChanged))
3806 q->updateCursorRectangle();
3816void QQuickTextInputPrivate::internalSetText(
const QString &
txt,
int pos,
bool edited)
3829 m_undoPreeditState = -1;
3834 bool changed = finishChange(-1,
true, edited);
3835#if !QT_CONFIG(accessibility)
3839 if (changed && QAccessible::isActive()) {
3840 if (
QObject *acc = QQuickAccessibleAttached::findAccessible(
q, QAccessible::EditableText)) {
3841 QAccessibleTextUpdateEvent ev(acc, 0, oldText,
m_text);
3842 QAccessible::updateAccessibility(&ev);
3855void QQuickTextInputPrivate::addCommand(
const Command &cmd)
3877void QQuickTextInputPrivate::internalInsert(
const QString &
s)
3887 for (
int i = 0;
i < ms.
size(); ++
i) {
3897 if (remaining != 0) {
3900 for (
auto e : remainingStr)
3918void QQuickTextInputPrivate::internalDelete(
bool wasBackspace)
3944void QQuickTextInputPrivate::removeSelectedText()
3982bool QQuickTextInputPrivate::separateSelection()
3999void QQuickTextInputPrivate::parseInputMask(
const QString &maskFields)
4001 int delimiter = maskFields.indexOf(
QLatin1Char(
';'));
4002 if (maskFields.isEmpty() || delimiter == 0) {
4011 if (delimiter == -1) {
4016 m_blank = (delimiter + 1 < maskFields.size()) ? maskFields[delimiter + 1] :
QLatin1Char(
' ');
4058 switch (
c.unicode()) {
4103 switch (
mask.unicode()) {
4113 if (
key.isLetterOrNumber())
4137 if (
key.isNumber() &&
key.digitValue() > 0)
4178QQuickTextInputPrivate::ValidatorState QQuickTextInputPrivate::hasAcceptableInput(
const QString &
str)
const
4180#if QT_CONFIG(validator)
4186 return ValidatorState(
state);
4191 return AcceptableInput;
4194 return InvalidInput;
4199 return InvalidInput;
4202 return InvalidInput;
4205 return AcceptableInput;
4249 int n = findInMask(
i,
true,
true,
str[strIndex]);
4257 n = findInMask(
i,
true,
false,
str[strIndex]);
4320 for (
int i = 0;
i <
end; ++
i) {
4334int QQuickTextInputPrivate::findInMask(
int pos,
bool forward,
bool findSeparator,
QChar searchChar)
const
4340 int step = forward ? 1 : -1;
4344 if (findSeparator) {
4349 if (searchChar.isNull())
4351 else if (isValidInput(searchChar,
m_maskData[
i].maskChar))
4360void QQuickTextInputPrivate::internalUndo(
int until)
4393 if (
next.type != cmd.type
4404void QQuickTextInputPrivate::internalRedo()
4438 if (
next.type != cmd.type
4449void QQuickTextInputPrivate::emitUndoRedoChanged()
4452 const bool previousUndo =
canUndo;
4453 const bool previousRedo =
canRedo;
4459 emit q->canUndoChanged();
4461 emit q->canRedoChanged();
4470bool QQuickTextInputPrivate::emitCursorPositionChanged()
4476 q->updateCursorRectangle();
4477 emit q->cursorPositionChanged();
4482 emit q->selectionStartChanged();
4486 emit q->selectionEndChanged();
4490#if QT_CONFIG(accessibility)
4491 if (QAccessible::isActive()) {
4492 if (
QObject *acc = QQuickAccessibleAttached::findAccessible(
q, QAccessible::EditableText)) {
4493 QAccessibleTextCursorEvent ev(acc,
m_cursor);
4494 QAccessible::updateAccessibility(&ev);
4543 if (
event->timerId() ==
d->m_blinkTimer) {
4544 d->m_blinkStatus = !
d->m_blinkStatus;
4548 }
else if (
event->timerId() ==
d->m_passwordEchoTimer.timerId()) {
4549 d->m_passwordEchoTimer.stop();
4550 d->updateDisplayText();
4551 updateCursorRectangle();
4560 if (hasAcceptableInput(
m_text) == AcceptableInput ||
fixup()) {
4568 emit q->editingFinished();
4583 && !
event->text().isEmpty()
4595#if QT_CONFIG(shortcut)
4601#if QT_CONFIG(shortcut)
4611#if QT_CONFIG(clipboard)
4696 deleteStartOfWord();
4700#if QT_CONFIG(clipboard)
4708 bool handled =
false;
4710 switch (
event->key()) {
4713 deleteStartOfWord();
4720 switch (
event->key()) {
4744 && !(
m_cursor == q_func()->text().size())) {
4766void QQuickTextInputPrivate::deleteStartOfWord()
4773 removeSelectedText();
4774 finishChange(priorState);
4783void QQuickTextInputPrivate::deleteEndOfWord()
4792 removeSelectedText();
4793 finishChange(priorState);
4802void QQuickTextInputPrivate::deleteEndOfLine()
4809 removeSelectedText();
4810 finishChange(priorState);
4822void QQuickTextInput::ensureVisible(
int position)
4826 updateCursorRectangle(
false);
4840void QQuickTextInput::clear()
4873 return d->padding();
4882 d->extra.value().padding =
padding;
4884 updateCursorRectangle();
4885 emit paddingChanged();
4886 if (!
d->extra.isAllocated() || !
d->extra->explicitTopPadding)
4887 emit topPaddingChanged();
4888 if (!
d->extra.isAllocated() || !
d->extra->explicitLeftPadding)
4889 emit leftPaddingChanged();
4890 if (!
d->extra.isAllocated() || !
d->extra->explicitRightPadding)
4891 emit rightPaddingChanged();
4892 if (!
d->extra.isAllocated() || !
d->extra->explicitBottomPadding)
4893 emit bottomPaddingChanged();
4904 if (
d->extra.isAllocated() &&
d->extra->explicitTopPadding)
4905 return d->extra->topPadding;
4906 return d->padding();
4918 d->setTopPadding(0,
true);
4924 if (
d->extra.isAllocated() &&
d->extra->explicitLeftPadding)
4925 return d->extra->leftPadding;
4926 return d->padding();
4938 d->setLeftPadding(0,
true);
4944 if (
d->extra.isAllocated() &&
d->extra->explicitRightPadding)
4945 return d->extra->rightPadding;
4946 return d->padding();
4958 d->setRightPadding(0,
true);
4964 if (
d->extra.isAllocated() &&
d->extra->explicitBottomPadding)
4965 return d->extra->bottomPadding;
4966 return d->padding();
4978 d->setBottomPadding(0,
true);
4981#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
4982void QQuickTextInput::setOldSelectionDefault()
4985 d->selectByMouse =
false;
4986 d->selectByTouchDrag =
true;
4987 qCDebug(lcQuickTextInput,
"pre-6.4 behavior chosen: selectByMouse defaults false; if enabled, touchscreen acts like a mouse");
4994 setOldSelectionDefault();
5000#include "moc_qquicktextinput_p.cpp"
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
bool isActive() const noexcept
Returns true if the timer is running and has not been stopped; otherwise returns false.
The QClipboard class provides access to the window system clipboard.
Mode
\keyword clipboard mode
The QColor class provides colors based on RGB, HSV or CMYK values.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QFocusEvent class contains event parameters for widget focus events.
\reentrant \inmodule QtGui
\reentrant \inmodule QtGui
int horizontalAdvance(const QString &, int len=-1) const
Returns the horizontal advance in pixels of the first len characters of text.
static QClipboard * clipboard()
Returns the object for interacting with the clipboard.
static QStyleHints * styleHints()
Returns the application's style hints.
static QInputMethod * inputMethod()
returns the input method.
The QKeyEvent class describes a key event.
static constexpr Policy Preferred
static constexpr Policy Fixed
qsizetype size() const noexcept
qsizetype length() const noexcept
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
bool hasText() const
Returns true if the object can return plain text (MIME type text/plain); otherwise returns false.
QString text() const
Returns a plain text (MIME type text/plain) representation of 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)
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
\inmodule QtCore\reentrant
bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns fa...
\inmodule QtCore\reentrant
The QQmlComponent class encapsulates a QML component definition.
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
static bool isEventFromMouseOrTouchpad(const QPointerEvent *ev)
void setSizePolicy(const QLayoutPolicy::Policy &horizontalPolicy, const QLayoutPolicy::Policy &verticalPolicy)
QQuickAnchorLine top() const
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
virtual void focusOutEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive focus-out events for an item.
virtual void mouseReleaseEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
Flags flags() const
Returns the item flags for this item.
virtual void mouseDoubleClickEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse double-click events for an ite...
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
virtual void keyPressEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key press events for an item.
qreal x
\qmlproperty real QtQuick::Item::x \qmlproperty real QtQuick::Item::y \qmlproperty real QtQuick::Item...
qreal y
Defines the item's y position relative to its parent.
bool hasActiveFocus() const
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
void setKeepMouseGrab(bool)
Sets whether the mouse input should remain exclusively with this item.
Q_INVOKABLE void forceActiveFocus()
\qmlmethod point QtQuick::Item::mapToItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::...
bool smooth
\qmlproperty bool QtQuick::Item::smooth
virtual QRectF clipRect() const
Returns the rectangular area within this item that is currently visible in \l viewportItem(),...
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
@ ItemDevicePixelRatioHasChanged
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive focus-in events for an item.
void update()
Schedules a call to updatePaintNode() for this item.
void polish()
Schedules a polish event for this item.
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
void updatePasswordEchoEditing(bool editing)
qreal getImplicitWidth() const override
void cancelPasswordEchoTimer()
void setLeftPadding(qreal value, bool reset=false)
bool isImplicitResizeEnabled() const
void setSelection(int start, int length)
void setImplicitResizeEnabled(bool enabled)
qreal calculateImplicitWidthForText(const QString &text) const
void updateCursorBlinking()
QQuickTextInput::WrapMode wrapMode
Qt::LayoutDirection layoutDirection() const
int selectionStart() const
void cursorWordBackward(bool mark)
QChar m_passwordCharacter
void mirrorChange() override
Qt::LayoutDirection textDirection() const
void setLayoutDirection(Qt::LayoutDirection direction)
void setRightPadding(qreal value, bool reset=false)
Qt::CursorMoveStyle cursorMoveStyle() const
void updateHorizontalScroll()
void selectWordAtPos(int)
QBasicTimer m_passwordEchoTimer
QQuickTextInput::VAlignment vAlign
bool m_passwordEchoEditing
bool isRedoAvailable() const
bool isUndoAvailable() const
QRectF anchorRectangle() const
void moveCursor(int pos, bool mark=false)
void setTopPadding(qreal value, bool reset=false)
bool hasSelectedText() const
std::unique_ptr< MaskInputData[]> m_maskData
int prevMaskBlank(int pos)
QLazilyAllocated< ExtraData > extra
QQuickTextInput::HAlignment hAlign
bool determineHorizontalAlignment()
void updateBaselineOffset()
QQuickTextInputPrivate::updateBaselineOffset.
QVector< Command > m_history
void cursorForward(bool mark, int steps)
bool sendMouseEventToInputContext(QMouseEvent *event)
QString selectedText() const
void setBottomPadding(qreal value, bool reset=false)
Qt::LayoutDirection m_layoutDirection
void setBlinkingCursorEnabled(bool enable)
void processKeyEvent(QKeyEvent *ev)
void ensureVisible(int position, int preeditCursor=0, int preeditLength=0)
QInputControl * m_inputControl
QQuickTextInput::RenderType renderType
bool setHAlign(QQuickTextInput::HAlignment, bool forceAlign=false)
int positionAt(qreal x, qreal y, QTextLine::CursorPosition position) const
void insert(const QString &)
void cursorWordForward(bool mark)
QList< int > m_transactions
QQuickTextInput::EchoMode m_echoMode
int nextMaskBlank(int pos)
bool requireImplicitWidth
void updateVerticalScroll()
void handleFocusEvent(QFocusEvent *event)
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
QRectF boundingRect() const override
Returns the extents of the item in its own coordinate system: a rectangle from {0,...
bool event(QEvent *e) override
\reimp
void inputMethodComposingChanged()
void passwordCharacterChanged()
void redo()
\qmlmethod QtQuick::TextInput::redo()
void setMaxLength(int ml)
void undo()
\qmlmethod QtQuick::TextInput::undo()
VAlignment vAlign() const
void keyPressEvent(QKeyEvent *ev) override
This event handler can be reimplemented in a subclass to receive key press events for an item.
void selectAll()
\qmlmethod QtQuick::TextInput::selectAll()
void setBottomPadding(qreal padding)
QString preeditText
\qmlproperty string QtQuick::TextInput::preeditText \readonly
void activeFocusOnPressChanged(bool activeFocusOnPress)
void setRenderType(RenderType renderType)
void updatePolish() override
This function should perform any layout as required for this item.
void selectionColorChanged()
void setOverwriteMode(bool overwrite)
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
Q_INVOKABLE void moveCursorSelection(int pos)
QRectF clipRect() const override
Returns the rectangular area within this item that is currently visible in \l viewportItem(),...
void setPasswordMaskDelay(int delay)
void mouseReleaseEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
void setRightPadding(qreal padding)
Qt::InputMethodHints inputMethodHints
Q_INVOKABLE void positionAt(QQmlV4FunctionPtr args) const
\qmlmethod int QtQuick::TextInput::positionAt(real x, real y, CursorPosition position)
void setFocusOnPress(bool)
void setWrapMode(WrapMode w)
void fontChanged(const QFont &font)
void resetBottomPadding()
void setPersistentSelection(bool persist)
QQuickTextInput(QQuickItem *parent=nullptr)
\qmltype TextInput \instantiates QQuickTextInput \inqmlmodule QtQuick\inherits Item
void setPasswordCharacter(const QString &str)
void focusOutEvent(QFocusEvent *event) override
This event handler can be reimplemented in a subclass to receive focus-out events for an item.
void setHAlign(HAlignment align)
void readOnlyChanged(bool isReadOnly)
void echoModeChanged(QQuickTextInput::EchoMode echoMode)
void setSelectByMouse(bool)
void setEchoMode(EchoMode echo)
bool focusOnPress() const
\qmlproperty bool QtQuick::TextInput::activeFocusOnPress
int maxLength() const
\qmlproperty int QtQuick::TextInput::maximumLength The maximum permitted length of the text in the Te...
void cursorVisibleChanged(bool isCursorVisible)
void verticalAlignmentChanged(QQuickTextInput::VAlignment alignment)
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
void inputMethodHintsChanged()
void mouseSelectionModeChanged(QQuickTextInput::SelectionMode mode)
void setText(const QString &)
void focusInEvent(QFocusEvent *event) override
This event handler can be reimplemented in a subclass to receive focus-in events for an item.
void overwriteModeChanged(bool overwriteMode)
void setVAlign(VAlignment align)
bool isReadOnly() const
\qmlproperty bool QtQuick::TextInput::readOnly
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void setInputMask(const QString &im)
QString passwordCharacter
void setSelectedTextColor(const QColor &c)
void selectedTextColorChanged()
void setSelectionColor(const QColor &c)
Q_INVOKABLE QString getText(int start, int end) const
\qmlmethod string QtQuick::TextInput::getText(int start, int end)
bool hasAcceptableInput() const
\qmlproperty bool QtQuick::TextInput::acceptableInput \readonly
void mousePressEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
void setColor(const QColor &c)
void insert(int position, const QString &text)
\qmlmethod QtQuick::TextInput::insert(int position, string text)
void autoScrollChanged(bool autoScroll)
void setCursorPosition(int cp)
HAlignment effectiveHAlign() const
void mouseUngrabEvent() override
This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has oc...
void mouseDoubleClickEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse double-click events for an ite...
void setPadding(qreal padding)
void selectByMouseChanged(bool selectByMouse)
void mouseMoveEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
void select(int start, int end)
\qmlmethod QtQuick::TextInput::select(int start, int end)
void invalidate() override
bool isCursorVisible() const
\qmlproperty bool QtQuick::TextInput::cursorVisible Set to true when the TextInput shows a cursor.
HAlignment hAlign() const
\qmlproperty enumeration QtQuick::TextInput::effectiveHorizontalAlignment \readonly
bool isRightToLeft(int start, int end)
\qmlmethod QtQuick::TextInput::isRightToLeft(int start, int end)
void setLeftPadding(qreal padding)
void setMouseSelectionMode(SelectionMode mode)
void selectWord()
\qmlmethod QtQuick::TextInput::selectWord()
void inputMaskChanged(const QString &inputMask)
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void setCursorDelegate(QQmlComponent *)
void maximumLengthChanged(int maximumLength)
void remove(int start, int end)
\qmlmethod QtQuick::TextInput::remove(int start, int end)
void resetPasswordMaskDelay()
SelectionMode mouseSelectionMode
void persistentSelectionChanged()
bool isInputMethodComposing() const
\qmlproperty bool QtQuick::TextInput::inputMethodComposing \readonly
void selectionEndChanged()
void setTopPadding(qreal padding)
Q_INVOKABLE QRectF positionToRectangle(int pos) const
\qmlmethod rect QtQuick::TextInput::positionToRectangle(int pos)
void setCursorVisible(bool on)
void selectionStartChanged()
void deselect()
\qmlmethod QtQuick::TextInput::deselect()
QQmlComponent * cursorDelegate
void setFont(const QFont &font)
void setInputMethodHints(Qt::InputMethodHints hints)
static qreal alignedX(qreal textWidth, qreal itemWidth, int alignment)
static void createCursor(Private *d)
static qreal alignedY(qreal textHeight, qreal itemHeight, int alignment)
static void setCursorDelegate(Private *d, QQmlComponent *delegate)
\inmodule QtCore\reentrant
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
void setSelectionTextColor(QColor selectionTextColor) override
Sets the color of the selection text to selectionTextColor when any part of the text is marked as sel...
void setTextStyle(TextStyle textStyle) override
Sets the style of the rendered text to textStyle.
void clear() override
Clears the contents of the node, deleting nodes and other data that represents the layouts and docume...
void setFiltering(QSGTexture::Filtering filtering) override
Sets the sampling mode used when scaling images that are part of the displayed text to filtering.
void setRenderType(RenderType renderType) override
Sets the type of glyph node in use to renderType.
void setColor(QColor color) override
Sets the main color to use when rendering the text to color.
void setViewport(const QRectF &viewport) override
Sets the bounding rect of the viewport where the text is displayed to viewport.
void setSelectionColor(QColor selectionColor) override
Sets the color of the selection background to color when any part of the text is marked as selected.
void setCursor(const QRectF &rect, const QColor &color)
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
void addTextLayout(QPointF position, QTextLayout *layout, int selectionStart=-1, int selectionCount=-1, int lineStart=0, int lineCount=-1)
Adds the contents of layout to the text node at position.
RenderType
This enum type describes type of glyph node used for rendering the text.
constexpr qreal height() const noexcept
Returns the height.
constexpr QStringView left(qsizetype n) const noexcept
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 &
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString & fill(QChar c, qsizetype size=-1)
Sets every character in the string to character ch.
QString & replace(qsizetype i, qsizetype len, QChar after)
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
qsizetype size() const noexcept
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
QString & insert(qsizetype i, QChar c)
QString toLower() const &
QChar * data()
Returns a pointer to the data stored in the QString.
QString & append(QChar c)
bool isRightToLeft() const
Returns true if the string is read right to left.
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
QString toUpper() const &
void cursorFlashTimeChanged(int cursorFlashTime)
QTextCharFormat toCharFormat() const
Returns this format as a character format.
const QTextOption & textOption() const
Returns the current text option used to control the layout process.
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
void setFont(const QFont &f)
Sets the layout's font to the given font.
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
void beginLayout()
Begins the layout process.
void setFormats(const QList< FormatRange > &overrides)
void setText(const QString &string)
Sets the layout's text to the given string.
QString text() const
Returns the layout's text.
int previousCursorPosition(int oldPos, CursorMode mode=SkipCharacters) const
Returns the first valid cursor position before oldPos that respects the given cursor mode.
int lineCount() const
Returns the number of lines in this text layout.
int preeditAreaPosition() const
Returns the position of the area in the text layout that will be processed before editing occurs.
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
int nextCursorPosition(int oldPos, CursorMode mode=SkipCharacters) const
Returns the next valid cursor position after oldPos that respects the given cursor mode.
void setTextOption(const QTextOption &option)
Sets the text option structure that controls the layout process to the given option.
void endLayout()
Ends the layout process.
QString preeditAreaText() const
Returns the text that is inserted in the layout before editing occurs.
void setPreeditArea(int position, const QString &text)
Sets the position and text of the area in the layout that is processed before editing occurs.
QRectF rect() const
Returns the line's bounding rectangle.
qreal height() const
Returns the line's height.
qreal cursorToX(int *cursorPos, Edge edge=Leading) const
Converts the cursor position cursorPos to the corresponding x position inside the line,...
qreal naturalTextWidth() const
Returns the width of the line that is occupied by text.
qreal y() const
Returns the line's y position.
CursorPosition
\value CursorBetweenCharacters \value CursorOnCharacter
@ CursorBetweenCharacters
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
void setTextDirection(Qt::LayoutDirection aDirection)
Sets the direction of the text layout defined by the option to the given direction.
void setUseDesignMetrics(bool b)
If enable is true then the layout will use design metrics; otherwise it will use the metrics of the p...
WrapMode
This enum describes how text is wrapped in a document.
The QValidator class provides validation of input text.
State
This enum type defines the states in which a validated string can exist.
void textChanged(const QString &newText)
Combined button and popup list for selecting options.
@ ActiveWindowFocusReason
static jboolean copy(JNIEnv *, jobject)
static jboolean paste(JNIEnv *, jobject)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
int qRound(qfloat16 d) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble top
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLdouble GLdouble GLdouble GLdouble q
#define qmlobject_disconnect(Sender, SenderType, Signal, Receiver, ReceiverType, Method)
Disconnect Signal of Sender from Method of Receiver.
#define qmlobject_connect(Sender, SenderType, Signal, Receiver, ReceiverType, Method)
Connect Signal of Sender to Method of Receiver.
#define DEFINE_BOOL_CONFIG_OPTION(name, var)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
void forceUpdate(QQuickItem *item)
static const struct ImageFormatTab unknown[]
QLatin1StringView QLatin1String
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
#define QT_CONFIG(feature)
#define QT_VERSION_CHECK(major, minor, patch)
static QString escape(const QString &input)
myObject disconnect()
[26]
\inmodule QtCore \reentrant