12#include <QtCore/qmath.h>
13#include <QtGui/qguiapplication.h>
14#include <QtGui/qevent.h>
15#include <QtGui/qpainter.h>
16#include <QtGui/qtextobject.h>
17#include <QtGui/qtexttable.h>
18#include <QtQml/qqmlinfo.h>
19#include <QtQuick/qsgsimplerectnode.h>
21#include <private/qqmlglobal_p.h>
22#include <private/qqmlproperty_p.h>
23#include <private/qtextengine_p.h>
24#include <private/qsgadaptationlayer_p.h>
25#include <QtQuick/private/qquickpixmapcache_p.h>
27#if QT_CONFIG(accessibility)
28#include <private/qquickaccessibleattached_p.h>
40using namespace
Qt::StringLiterals;
103#if !defined(QQUICKTEXT_LARGETEXT_THRESHOLD)
104 #define QQUICKTEXT_LARGETEXT_THRESHOLD 10000
113 RootNode() : cursorNode(
nullptr), frameDecorationsNode(
nullptr)
118 if (frameDecorationsNode) {
119 removeChildNode(frameDecorationsNode);
120 delete frameDecorationsNode;
122 frameDecorationsNode = newNode;
129 removeChildNode(cursorNode);
131 cursorNode = newNode;
133 appendChildNode(cursorNode);
169#if QT_CONFIG(texthtmlparser)
171 d->text =
d->control->toHtml();
174#if QT_CONFIG(textmarkdownwriter)
176 d->text =
d->control->toMarkdown();
179 d->text =
d->control->toPlainText();
180 d->textCached =
true;
424 }
else if (
d->richText) {
425#if QT_CONFIG(texthtmlparser)
426 d->control->setHtml(
text);
428 d->control->setPlainText(
text);
430 }
else if (
d->markdownText) {
431 d->control->setMarkdownText(
text);
433 d->control->setPlainText(
text);
443void QQuickTextEdit::q_invalidate()
447 if (
d->document !=
nullptr)
448 d->document->markContentsDirty(0,
d->document->characterCount());
449 invalidateFontCaches();
470 return d->control->preeditText();
539 auto mightBeRichText = [
this]() {
543 auto findSourceFormat = [
d, mightBeRichText](
Qt::TextFormat detectedFormat) {
548 if (detectedFormat ==
Qt::AutoText && mightBeRichText())
564 bool textCachedChanged =
false;
565 bool converted =
false;
569 if (
d->quickDocument) {
575 const TextFormat sourceFormat = findSourceFormat(detectedFormat);
576 const TextFormat destinationFormat = findDestinationFormat(detectedFormat, sourceFormat);
578 d->richText = destinationFormat ==
RichText;
583 d->textCached =
false;
584 textCachedChanged =
true;
587 switch (destinationFormat) {
589#if QT_CONFIG(texthtmlparser)
594 d->control->setPlainText(
d->textCached ?
d->text :
d->control->toHtml());
598#if QT_CONFIG(textmarkdownwriter) && QT_CONFIG(textmarkdownreader)
603 d->control->setPlainText(
d->textCached ?
d->text :
d->control->toMarkdown());
609#if QT_CONFIG(texthtmlparser)
610 switch (sourceFormat) {
613 d->control->setHtml(
d->control->toHtml());
619 d->control->setHtml(
d->textCached ?
d->text :
d->control->toPlainText());
629#if QT_CONFIG(textmarkdownwriter) && QT_CONFIG(textmarkdownreader)
630 switch (sourceFormat) {
633 d->control->setMarkdownText(
d->control->toMarkdown());
639 d->control->setMarkdownText(
d->textCached ?
d->text :
d->control->toPlainText());
660 <<
"rich?" <<
d->richText <<
"md?" <<
d->markdownText
661 <<
"converted?" << converted <<
"cache invalidated?" << textCachedChanged;
664 d->control->setAcceptRichText(
d->format !=
PlainText);
666 if (textCachedChanged)
698 return d->renderType;
709 d->updateDefaultTextOption();
718 return d->sourceFont;
724 if (
d->sourceFont ==
font)
727 d->sourceFont =
font;
730 if (
d->font.pointSizeF() != -1) {
733 d->font.setPointSizeF(
size/2.0);
736 if (oldFont !=
d->font) {
737 d->document->setDefaultFont(
d->font);
740 moveCursorDelegate();
743 updateWholeDocument();
779 updateWholeDocument();
791 return d->selectionColor;
797 if (
d->selectionColor ==
color)
800 d->selectionColor =
color;
801 updateWholeDocument();
813 return d->selectedTextColor;
819 if (
d->selectedTextColor ==
color)
822 d->selectedTextColor =
color;
823 updateWholeDocument();
870 d->updateDefaultTextOption();
878 d->hAlignImplicit =
true;
880 d->updateDefaultTextOption();
889 if (!
d->hAlignImplicit &&
d->effectiveLayoutMirror) {
901 return effectiveAlignment;
907 if (
hAlign == align && !forceAlign)
911 const auto oldEffectiveHAlign =
q->effectiveHAlign();
916 emit q->horizontalAlignmentChanged(align);
919 if (
q->effectiveHAlign() != oldEffectiveHAlign) {
920 emit q->effectiveHorizontalAlignmentChanged();
924 if (forceAlign && wasImplicit) {
927 emit q->effectiveHorizontalAlignmentChanged();
935 while (!character->isNull()) {
936 switch (character->direction()) {
977 if (
q->isComponentComplete()) {
981 emit q->effectiveHorizontalAlignmentChanged();
989 qCDebug(lcVP) <<
q <<
"sees that" << transformedItem <<
"moved in VP" <<
q->clipRect();
998 qCDebug(lcVP) <<
"viewport" << vp <<
"now goes beyond rendered region" <<
renderedRegion <<
"; updating";
999 q->updateWholeDocument();
1012Qt::InputMethodHints QQuickTextEditPrivate::effectiveInputMethodHints()
const
1018#if QT_CONFIG(accessibility)
1019void QQuickTextEditPrivate::accessibilityActiveChanged(
bool active)
1025 if (QQuickAccessibleAttached *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(
1026 qmlAttachedPropertiesObject<QQuickAccessibleAttached>(
q,
true))) {
1027 accessibleAttached->setRole(effectiveAccessibleRole());
1028 accessibleAttached->set_readOnly(
q->isReadOnly());
1032QAccessible::Role QQuickTextEditPrivate::accessibleRole()
const
1034 return QAccessible::EditableText;
1041 qreal oldPadding =
q->topPadding();
1048 q->updateWholeDocument();
1049 emit q->topPaddingChanged();
1056 qreal oldPadding =
q->leftPadding();
1063 q->updateWholeDocument();
1064 emit q->leftPaddingChanged();
1071 qreal oldPadding =
q->rightPadding();
1078 q->updateWholeDocument();
1079 emit q->rightPaddingChanged();
1086 qreal oldPadding =
q->bottomPadding();
1089 extra.value().explicitBottomPadding = !
reset;
1093 q->updateWholeDocument();
1094 emit q->bottomPaddingChanged();
1100 return !
extra.isAllocated() ||
extra->implicitResize;
1106 extra.value().implicitResize =
false;
1107 else if (
extra.isAllocated())
1108 extra->implicitResize =
true;
1123 d->updateDefaultTextOption();
1125 moveCursorDelegate();
1158 if (
mode ==
d->wrapMode)
1161 d->updateDefaultTextOption();
1174 return d->lineCount;
1193 return qMax(0,
d->document->characterCount() - 1);
1205 return d->contentSize.width();
1217 return d->contentSize.height();
1232 if (
d->baseUrl.isEmpty()) {
1245 d->document->setBaseUrl(
url);
1270 return d->control->cursorRect(
c).translated(
d->xoff,
d->yoff);
1296 const int preeditLength =
layout
1297 ?
layout->preeditAreaText().size()
1299 if (preeditLength > 0
1300 &&
d->document->documentLayout()->blockBoundingRect(
cursor.block()).contains(
x,
y)) {
1301 r =
r >
cursor.position() + preeditLength
1323 if (!
d->cursorSelection)
1325 return d->cursorSelection;
1372 d->control->setTextCursor(
cursor);
1421 d->control->setTextCursor(
cursor);
1434 return d->cursorVisible;
1440 if (
d->cursorVisible == on)
1442 d->cursorVisible = on;
1445 if (!on && !
d->persistentSelection)
1446 d->control->setCursorIsFocusIndicator(
true);
1447 d->control->setCursorVisible(on);
1466 return d->control->textCursor().position();
1472 if (pos < 0 || pos >=
d->document->characterCount())
1478 d->control->setTextCursor(
cursor);
1479 d->control->updateCursorRectangle(
true);
1498 return d->cursorComponent;
1507void QQuickTextEdit::createCursor()
1510 d->cursorPending =
true;
1527 return d->control->textCursor().selectionStart();
1543 return d->control->textCursor().selectionEnd();
1563#if QT_CONFIG(texthtmlparser)
1564 return d->richText ||
d->markdownText
1565 ?
d->control->textCursor().selectedText()
1566 :
d->control->textCursor().selection().toPlainText();
1568 return d->control->textCursor().selection().toPlainText();
1581 return d->focusOnPress;
1587 if (
d->focusOnPress == on)
1589 d->focusOnPress = on;
1602 return d->persistentSelection;
1608 if (
d->persistentSelection == on)
1610 d->persistentSelection = on;
1622 return d->textMargin;
1628 if (
d->textMargin == margin)
1630 d->textMargin = margin;
1631 d->document->setDocumentMargin(
d->textMargin);
1678 return d->inputMethodHints;
1689 if (hints ==
d->inputMethodHints)
1692 d->inputMethodHints = hints;
1701 if (!
d->inLayout && ((newGeometry.
width() != oldGeometry.
width())
1704 updateWholeDocument();
1706 moveCursorDelegate();
1722 updateWholeDocument();
1744 if (!
d->text.isEmpty()) {
1745#if QT_CONFIG(texthtmlparser)
1747 d->control->setHtml(
d->text);
1750#if QT_CONFIG(textmarkdownreader)
1751 if (
d->markdownText)
1752 d->control->setMarkdownText(
d->text);
1755 d->control->setPlainText(
d->text);
1759 d->determineHorizontalAlignment();
1760 d->updateDefaultTextOption();
1768#if QT_CONFIG(accessibility)
1769 if (QAccessible::isActive())
1770 d->accessibilityActiveChanged(
true);
1777 return d->pixmapsInProgress.size();
1797 if (
d->selectByKeyboardSet)
1798 return d->selectByKeyboard;
1806 if (!
d->selectByKeyboardSet || was != on) {
1807 d->selectByKeyboardSet =
true;
1808 d->selectByKeyboard = on;
1813 emit selectByKeyboardChanged(on);
1843 return d->selectByMouse;
1849 if (
d->selectByMouse == on)
1852 d->selectByMouse = on;
1859#if QT_CONFIG(cursor)
1860 d->updateMouseCursorShape();
1878 return d->mouseSelectionMode;
1884 if (
d->mouseSelectionMode !=
mode) {
1885 d->mouseSelectionMode =
mode;
1906 setFlag(QQuickItem::ItemAcceptsInputMethod, !
r);
1909 if (
d->selectByMouse)
1911 if (
d->selectByKeyboardSet &&
d->selectByKeyboard)
1913 else if (!
d->selectByKeyboardSet && !
r)
1917 d->control->setTextInteractionFlags(
flags);
1923#if QT_CONFIG(cursor)
1924 d->updateMouseCursorShape();
1926 q_canPasteChanged();
1928 if (!
d->selectByKeyboardSet)
1929 emit selectByKeyboardChanged(!
r);
1936#if QT_CONFIG(accessibility)
1937 if (QAccessible::isActive()) {
1939 accessibleAttached->set_readOnly(
r);
1963 return d->control->cursorRect().translated(
d->xoff,
d->yoff);
1971 if (
event->isAccepted())
1994 return d->control->overwriteMode();
2000 d->control->setOverwriteMode(overwrite);
2011 if (!
event->isAccepted())
2023 if (!
event->isAccepted())
2037 d->control->setTextCursor(
c);
2048 d->control->selectAll();
2061 d->control->setTextCursor(
c);
2080 if (
start < 0 || end < 0 || start >=
d->document->characterCount() ||
end >=
d->document->characterCount())
2087 d->control->setTextCursor(
cursor);
2092 updateInputMethod();
2105 qmlWarning(
this) <<
"isRightToLeft(start, end) called with the end property being smaller than the start.";
2112#if QT_CONFIG(clipboard)
2118void QQuickTextEdit::cut()
2129void QQuickTextEdit::copy()
2140void QQuickTextEdit::paste()
2143 d->control->paste();
2184 if (
d->focusOnPress){
2190 qGuiApp->inputMethod()->show();
2195 if (!
event->isAccepted())
2208 if (!
event->isAccepted())
2220 if (!
event->isAccepted())
2232 if (!
event->isAccepted())
2262 v = (bool)(
flags() & ItemAcceptsInputMethod);
2265 v = (int)
d->effectiveInputMethodHints();
2268 v = QQuickItem::inputMethodQuery(
property);
2278 v =
QVariant(
v.toRectF().translated(
d->xoff,
d->yoff));
2294void QQuickTextEdit::triggerPreprocess()
2322 auto existingJobIter = std::find_if(
2323 d->pixmapsInProgress.cbegin(),
d->pixmapsInProgress.cend(),
2324 [&
url](
const auto *job) { return job->url() == url; } );
2325 if (existingJobIter !=
d->pixmapsInProgress.cend()) {
2329 d->pixmapsInProgress.erase(existingJobIter);
2333 qCDebug(lcTextEdit) <<
"already downloading" <<
url;
2346 p->connectFinished(
this,
SLOT(resourceRequestFinished()));
2347 d->pixmapsInProgress.append(
p);
2349 return p->isReady() ?
p->image() :
QVariant();
2355void QQuickTextEdit::resourceRequestFinished()
2358 for (
auto it =
d->pixmapsInProgress.cbegin();
it !=
d->pixmapsInProgress.cend(); ++
it) {
2362 qCDebug(lcTextEdit) <<
"failed to load (error)" << job->
url();
2371 qCDebug(lcTextEdit) << (
res.isValid() ?
"done downloading" :
"failed to load") << job->
url() << job->
rect();
2372 d->pixmapsInProgress.erase(
it);
2377 if (
d->pixmapsInProgress.isEmpty()) {
2389 return n1.startPos() < n2.startPos();
2395 transformMatrix.
translate(topLeft.
x(), topLeft.
y());
2405void QQuickTextEdit::invalidateFontCaches()
2408 if (
d->document ==
nullptr)
2412 for (block =
d->document->firstBlock(); block.
isValid(); block = block.
next()) {
2427 if (
d->ownsDocument)
2430 d->ownsDocument =
false;
2431 d->control->setDocument(doc);
2437 engine->setTextColor(textColor);
2438 engine->setSelectedTextColor(selectedTextColor);
2439 engine->setSelectionColor(selectionColor);
2449 && oldNode !=
nullptr) {
2461 d->textNodeMap.clear();
2466 RootNode *rootNode =
static_cast<RootNode *
>(oldNode);
2468 std::optional<int> firstPosAcrossAllNodes;
2469 if (nodeIterator !=
d->textNodeMap.end())
2470 firstPosAcrossAllNodes = nodeIterator->startPos();
2472 while (nodeIterator !=
d->textNodeMap.end() && !nodeIterator->dirty())
2478 if (!oldNode || nodeIterator < d->textNodeMap.end() ||
d->textNodeMap.isEmpty()) {
2481 rootNode =
new RootNode;
2483 int firstDirtyPos = 0;
2484 if (nodeIterator !=
d->textNodeMap.end()) {
2485 firstDirtyPos = nodeIterator->startPos();
2489 auto it =
d->textNodeMap.constEnd();
2490 while (
it != nodeIterator) {
2494 firstCleanNode =
it->textNode();
2497 rootNode->removeChildNode(nodeIterator->textNode());
2498 delete nodeIterator->textNode();
2499 nodeIterator =
d->textNodeMap.erase(nodeIterator);
2500 }
while (nodeIterator !=
d->textNodeMap.constEnd() && nodeIterator->textNode() != firstCleanNode);
2511 rootNode->resetFrameDecorations(
d->createTextNode());
2512 resetEngine(&frameDecorationsEngine,
d->color,
d->selectedTextColor,
d->selectionColor);
2516 int currentNodeSize = 0;
2517 int nodeStart = firstDirtyPos;
2520 basePositionMatrix.
translate(basePosition.x(), basePosition.y());
2521 rootNode->setMatrix(basePositionMatrix);
2524 const TextNode firstCleanNode = (nodeIterator !=
d->textNodeMap.end()) ? *nodeIterator
2527 QList<QTextFrame *> frames;
2528 frames.append(
d->document->rootFrame());
2531 d->firstBlockInViewport = -1;
2532 d->firstBlockPastViewport = -1;
2533 int frameCount = -1;
2534 while (!frames.isEmpty()) {
2539 qCDebug(lcVP) <<
"frame" << frameCount << textFrame
2542 frames.append(textFrame->childFrames());
2543 frameDecorationsEngine.addFrameDecorations(
d->document, textFrame);
2546 if (textFrame->firstPosition() > textFrame->lastPosition()
2548 node =
d->createTextNode();
2549 updateNodeTransform(node,
d->document->documentLayout()->frameBoundingRect(textFrame).topLeft());
2550 const int pos = textFrame->firstPosition() - 1;
2553 QTextBlock block = textFrame->firstCursorPosition().block();
2554 nodeOffset =
d->document->documentLayout()->blockBoundingRect(block).topLeft();
2558 inView = coveredRegion.bottom() >=
viewport.top() && coveredRegion.top() <=
viewport.bottom();
2559 qCDebug(lcVP) <<
"non-flow frame" << coveredRegion <<
"in viewport?" << inView;
2564 pos, textFrame->frameFormat().position());
2569 QList<int> frameBoundaries;
2570 frameBoundaries.reserve(frames.size());
2572 frameBoundaries.append(
frame->firstPosition());
2573 std::sort(frameBoundaries.begin(), frameBoundaries.end());
2576 while (!
it.atEnd()) {
2578 if (block.
position() < firstDirtyPos) {
2583 if (!
engine.hasContents())
2584 nodeOffset =
d->document->documentLayout()->blockBoundingRect(block).topLeft();
2591 inView = coveredRegion.bottom() >
viewport.top();
2593 const bool potentiallyScrollingBackwards = firstPosAcrossAllNodes && *firstPosAcrossAllNodes == firstDirtyPos;
2594 if (
d->firstBlockInViewport < 0 && inView && potentiallyScrollingBackwards) {
2596 if (coveredRegion.top() >
viewport.top() + 1) {
2597 qCDebug(lcVP) <<
"checking backwards from block" << block.
blockNumber() <<
"@" << nodeOffset.y() << coveredRegion;
2598 while (
it != textFrame->
begin() &&
it.currentBlock().layout() &&
2599 it.currentBlock().layout()->boundingRect().top() + nodeOffset.y() >
viewport.top()) {
2600 nodeOffset =
d->document->documentLayout()->blockBoundingRect(
it.currentBlock()).topLeft();
2603 if (!
it.currentBlock().layout())
2606 block =
it.currentBlock();
2608 firstDirtyPos =
it.currentBlock().position();
2610 qCWarning(lcVP) <<
"failed to find a text block with layout during back-scrolling";
2613 qCDebug(lcVP) <<
"first block in viewport" << block.
blockNumber() <<
"@" << nodeOffset.y() << coveredRegion;
2615 d->renderedRegion = coveredRegion;
2617 if (nodeOffset.y() >
viewport.bottom()) {
2619 if (
d->firstBlockInViewport >= 0 &&
d->firstBlockPastViewport < 0) {
2621 <<
"@" << nodeOffset.y() <<
"total region rendered" <<
d->renderedRegion;
2626 if (inView && !block.
text().
isEmpty() && coveredRegion.isValid()) {
2627 d->renderedRegion =
d->renderedRegion.united(coveredRegion);
2630 if (!frames.isEmpty())
2634 if (inView &&
d->firstBlockInViewport < 0)
2638 bool createdNodeInView =
false;
2640 if (!
engine.hasContents()) {
2641 if (node && !node->
parent())
2642 d->addCurrentTextNodeToRoot(&
engine, rootNode, node, nodeIterator, nodeStart);
2643 node =
d->createTextNode();
2644 createdNodeInView =
true;
2649 currentNodeSize += block.
length();
2652 if ((
it.atEnd()) || block.
next().
position() >= firstCleanNode.startPos())
2655 if (node && (currentNodeSize >
nodeBreakingSize || lowerBound == frameBoundaries.constEnd() || *lowerBound > nodeStart)) {
2656 currentNodeSize = 0;
2658 d->addCurrentTextNodeToRoot(&
engine, rootNode, node, nodeIterator, nodeStart);
2659 if (!createdNodeInView)
2660 node =
d->createTextNode();
2668 d->addCurrentTextNodeToRoot(&
engine, rootNode, node, nodeIterator, nodeStart);
2672 rootNode->prependChildNode(rootNode->frameDecorationsNode);
2674 Q_ASSERT(nodeIterator ==
d->textNodeMap.end()
2675 || (nodeIterator->textNode() == firstCleanNode.textNode()
2676 && nodeIterator->startPos() == firstCleanNode.startPos()));
2678 if (firstCleanNode.textNode() !=
nullptr) {
2679 QPointF oldOffset = firstCleanNode.textNode()->matrix().map(
QPointF(0,0));
2680 QPointF currentOffset =
d->document->documentLayout()->blockBoundingRect(
2681 d->document->findBlock(firstCleanNode.startPos())).topLeft();
2682 QPointF delta = currentOffset - oldOffset;
2683 while (nodeIterator !=
d->textNodeMap.end()) {
2684 QMatrix4x4 transformMatrix = nodeIterator->textNode()->matrix();
2686 nodeIterator->textNode()->setMatrix(transformMatrix);
2694 std::sort(
d->textNodeMap.begin(),
d->textNodeMap.end());
2697 if (
d->cursorComponent ==
nullptr) {
2699 if (!
isReadOnly() &&
d->cursorVisible &&
d->control->cursorOn() &&
d->control->cursorVisible())
2700 cursor =
d->sceneGraphContext()->createInternalRectangleNode(
d->control->cursorRect(),
d->color);
2701 rootNode->resetCursorNode(
cursor);
2704 invalidateFontCaches();
2711 invalidateFontCaches();
2723 if (!
d->canPasteValid) {
2740 return d->document->isUndoAvailable();
2753 return d->document->isRedoAvailable();
2774 return d->control->hasImState();
2779 : explicitTopPadding(
false)
2780 , explicitLeftPadding(
false)
2781 , explicitRightPadding(
false)
2782 , explicitBottomPadding(
false)
2783 , implicitResize(true)
2791#if QT_CONFIG(clipboard)
2799 q->setFlag(QQuickItem::ItemAcceptsInputMethod);
2803 q->setAcceptHoverEvents(
true);
2814 q->setKeepMouseGrab(
true);
2826#if QT_CONFIG(clipboard)
2843#if QT_CONFIG(cursor)
2844 updateMouseCursorShape();
2852 if (!
q->isReadOnly() &&
q->hasActiveFocus() &&
qGuiApp)
2856void QQuickTextEdit::q_textChanged()
2859 d->textCached =
false;
2861 d->contentDirection =
d->textDirection(
it.text());
2865 d->determineHorizontalAlignment();
2866 d->updateDefaultTextOption();
2869 markDirtyNodesForRange(0,
d->document->characterCount(), 0);
2870 if (isComponentComplete()) {
2879void QQuickTextEdit::markDirtyNodesForRange(
int start,
int end,
int charDelta)
2893 if (
it != textNodeMapBegin) {
2896 it = std::lower_bound(textNodeMapBegin, textNodeMapEnd, otherDummy);
2900 while (
it != textNodeMapEnd) {
2901 if (
it->startPos() <=
end)
2904 it->moveStartPos(charDelta);
2911void QQuickTextEdit::q_contentsChange(
int pos,
int charsRemoved,
int charsAdded)
2915 const int editRange =
pos +
qMax(charsAdded, charsRemoved);
2916 const int delta = charsAdded - charsRemoved;
2918 markDirtyNodesForRange(
pos, editRange, delta);
2920 if (isComponentComplete()) {
2927void QQuickTextEdit::moveCursorDelegate()
2931 updateInputMethod();
2933 emit cursorRectangleChanged();
2936 QRectF cursorRect = cursorRectangle();
2937 d->cursorItem->setX(cursorRect.
x());
2938 d->cursorItem->setY(cursorRect.
y());
2939 d->cursorItem->setHeight(cursorRect.
height());
2942void QQuickTextEdit::updateSelection()
2947 if (
d->control->textCursor().hasSelection() ||
d->hadSelection) {
2948 markDirtyNodesForRange(
qMin(
d->lastSelectionStart,
d->control->textCursor().selectionStart()),
qMax(
d->control->textCursor().selectionEnd(),
d->lastSelectionEnd), 0);
2949 if (isComponentComplete()) {
2956 d->hadSelection =
d->control->textCursor().hasSelection();
2958 if (
d->lastSelectionStart !=
d->control->textCursor().selectionStart()) {
2959 d->lastSelectionStart =
d->control->textCursor().selectionStart();
2960 emit selectionStartChanged();
2962 if (
d->lastSelectionEnd !=
d->control->textCursor().selectionEnd()) {
2963 d->lastSelectionEnd =
d->control->textCursor().selectionEnd();
2964 emit selectionEndChanged();
2974 d->contentSize.width(),
2975 d->contentSize.height());
2977 int cursorWidth = 1;
2980 else if (!
d->document->isEmpty())
2984 r.setRight(
r.right() + cursorWidth);
2993 int cursorWidth = 1;
2995 cursorWidth =
d->cursorItem->width();
2996 if (!
d->document->isEmpty())
3001 r.setRight(
r.right() + cursorWidth);
3019void QQuickTextEdit::updateSize()
3022 if (!isComponentComplete()) {
3030 if (!
d->requireImplicitWidth) {
3033 if (
d->requireImplicitWidth)
3036 if (
d->requireImplicitWidth) {
3037 d->document->setTextWidth(-1);
3038 const qreal naturalWidth =
d->document->idealWidth();
3039 const bool wasInLayout =
d->inLayout;
3041 if (
d->isImplicitResizeEnabled())
3042 setImplicitWidth(naturalWidth + leftPadding() + rightPadding());
3043 d->inLayout = wasInLayout;
3047 const qreal newTextWidth =
width() - leftPadding() - rightPadding();
3048 if (
d->document->textWidth() != newTextWidth)
3049 d->document->setTextWidth(newTextWidth);
3050 }
else if (
d->wrapMode == NoWrap) {
3054 const qreal newTextWidth =
d->document->idealWidth();
3055 if (
d->document->textWidth() != newTextWidth)
3056 d->document->setTextWidth(newTextWidth);
3058 d->document->setTextWidth(-1);
3065 if (
d->isImplicitResizeEnabled()) {
3068 setImplicitSize(newWidth + leftPadding() + rightPadding(), newHeight + topPadding() + bottomPadding());
3070 setImplicitHeight(newHeight + topPadding() + bottomPadding());
3081 setBaselineOffset(
baseline +
d->yoff +
d->textMargin);
3084 if (
d->contentSize !=
size) {
3085 d->contentSize =
size;
3087 const bool wasInResize =
d->inResize;
3090 emit contentSizeChanged();
3091 d->inResize = wasInResize;
3096void QQuickTextEdit::updateWholeDocument()
3099 if (!
d->textNodeMap.isEmpty()) {
3104 if (isComponentComplete()) {
3111void QQuickTextEdit::invalidateBlock(
const QTextBlock &block)
3116 if (isComponentComplete()) {
3123void QQuickTextEdit::updateCursor()
3126 if (isComponentComplete() &&
isVisible()) {
3133void QQuickTextEdit::q_linkHovered(
const QString &link)
3136 emit linkHovered(link);
3137#if QT_CONFIG(cursor)
3139 d->updateMouseCursorShape();
3146void QQuickTextEdit::q_markerHovered(
bool hovered)
3149#if QT_CONFIG(cursor)
3151 d->updateMouseCursorShape();
3158void QQuickTextEdit::q_updateAlignment()
3161 if (
d->determineHorizontalAlignment()) {
3162 d->updateDefaultTextOption();
3164 moveCursorDelegate();
3168void QQuickTextEdit::updateTotalLines()
3178 subLines +=
layout->lineCount()-1;
3181 int newTotalLines =
d->document->lineCount() + subLines;
3182 if (
d->lineCount != newTotalLines) {
3183 d->lineCount = newTotalLines;
3184 emit lineCountChanged();
3192 const Qt::Alignment oldAlignment =
opt.alignment();
3203 opt.setAlignment((Qt::Alignment)(
int)(horizontalAlignment |
vAlign));
3205 opt.setAlignment(Qt::Alignment(
vAlign));
3209 opt.setTextDirection(
qGuiApp->inputMethod()->inputDirection());
3219 bool oldUseDesignMetrics =
opt.useDesignMetrics();
3222 if (oldWrapMode !=
opt.wrapMode() || oldAlignment !=
opt.alignment()
3223 || oldTextDirection !=
opt.textDirection()
3224 || oldUseDesignMetrics !=
opt.useDesignMetrics()) {
3260 d->handleFocusEvent(
event);
3267 d->handleFocusEvent(
event);
3275 if (!
q->isReadOnly())
3276 q->setCursorVisible(
focus);
3279 q->q_updateAlignment();
3282 qGuiApp->inputMethod()->show();
3284 q,
SLOT(q_updateAlignment()));
3289 q,
SLOT(q_updateAlignment()));
3297 emit q->editingFinished();
3319void QQuickTextEdit::q_canPasteChanged()
3322 bool old =
d->canPaste;
3323 d->canPaste =
d->control->canPaste();
3324 bool changed = old!=
d->canPaste || !
d->canPasteValid;
3325 d->canPasteValid =
true;
3327 emit canPasteChanged();
3346#if QT_CONFIG(texthtmlparser)
3347 return d->richText ||
d->markdownText
3349 :
cursor.selection().toPlainText();
3351 return cursor.selection().toPlainText();
3375#if QT_CONFIG(texthtmlparser)
3376 return cursor.selection().toHtml();
3378 return cursor.selection().toPlainText();
3380 }
else if (
d->markdownText) {
3381#if QT_CONFIG(textmarkdownwriter)
3382 return cursor.selection().toMarkdown();
3384 return cursor.selection().toPlainText();
3387 return cursor.selection().toPlainText();
3399 if (position < 0 || position >=
d->document->characterCount())
3405#if QT_CONFIG(texthtmlparser)
3410 }
else if (
d->markdownText) {
3411#if QT_CONFIG(textmarkdownreader)
3419 d->control->updateCursorRectangle(
false);
3436 cursor.removeSelectedText();
3437 d->control->updateCursorRectangle(
false);
3455 if (!
d->quickDocument) {
3457 connect(
d->quickDocument, &QQuickTextDocument::statusChanged,
d->quickDocument,
3458 [
d]() { d->onDocumentStatusChanged(); } );
3460 return d->quickDocument;
3469#if QT_CONFIG(cursor)
3470void QQuickTextEditPrivate::updateMouseCursorShape()
3510 return d->control->hoveredLink();
3512#if QT_CONFIG(cursor)
3515 return d->control->anchorAt(
pos);
3525 if (
d->isLinkHoveredConnected())
3533 if (
d->isLinkHoveredConnected())
3541 if (
d->isLinkHoveredConnected())
3562 if (!
d->document->isEmpty())
3566#if QT_CONFIG(texthtmlparser)
3571 }
else if (
d->format == MarkdownText) {
3572#if QT_CONFIG(textmarkdownreader)
3582 d->control->updateCursorRectangle(
false);
3597 return d->control->anchorAt(
QPointF(
x + topPadding(),
y + leftPadding()));
3614 return d->padding();
3623 d->extra.value().padding =
padding;
3625 if (isComponentComplete()) {
3629 emit paddingChanged();
3630 if (!
d->extra.isAllocated() || !
d->extra->explicitTopPadding)
3631 emit topPaddingChanged();
3632 if (!
d->extra.isAllocated() || !
d->extra->explicitLeftPadding)
3633 emit leftPaddingChanged();
3634 if (!
d->extra.isAllocated() || !
d->extra->explicitRightPadding)
3635 emit rightPaddingChanged();
3636 if (!
d->extra.isAllocated() || !
d->extra->explicitBottomPadding)
3637 emit bottomPaddingChanged();
3648 if (
d->extra.isAllocated() &&
d->extra->explicitTopPadding)
3649 return d->extra->topPadding;
3650 return d->padding();
3662 d->setTopPadding(0,
true);
3668 if (
d->extra.isAllocated() &&
d->extra->explicitLeftPadding)
3669 return d->extra->leftPadding;
3670 return d->padding();
3682 d->setLeftPadding(0,
true);
3688 if (
d->extra.isAllocated() &&
d->extra->explicitRightPadding)
3689 return d->extra->rightPadding;
3690 return d->padding();
3702 d->setRightPadding(0,
true);
3708 if (
d->extra.isAllocated() &&
d->extra->explicitBottomPadding)
3709 return d->extra->bottomPadding;
3710 return d->padding();
3722 d->setBottomPadding(0,
true);
3736 return d->document->defaultTextOption().tabStopDistance();
3742 QTextOption textOptions =
d->document->defaultTextOption();
3743 if (textOptions.tabStopDistance() ==
distance)
3747 d->document->setDefaultTextOption(textOptions);
3762void QQuickTextEdit::clear()
3765 d->resetInputMethod();
3766 d->control->clear();
3769#ifndef QT_NO_DEBUG_STREAM
3774 debug <<
"Node(startPos:" <<
n.m_startPos <<
"dirty:" <<
n.m_dirty <<
n.m_node <<
')';
3779#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
3780void QQuickTextEdit::setOldSelectionDefault()
3783 d->selectByMouse =
false;
3784 setKeepMouseGrab(
false);
3786 d->control->setTouchDragSelectionEnabled(
true);
3787 qCDebug(lcTextEdit,
"pre-6.4 behavior chosen: selectByMouse defaults false; if enabled, touchscreen acts like a mouse");
3794 setOldSelectionDefault();
3800#include "moc_qquicktextedit_p.cpp"
void registerHandler(int objectType, QObject *component)
Registers the given component as a handler for items of the given objectType.
void updateBlock(const QTextBlock &block)
The QClipboard class provides access to the window system clipboard.
The QColor class provides colors based on RGB, HSV or CMYK values.
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
The QFocusEvent class contains event parameters for widget focus events.
\reentrant \inmodule QtGui
\reentrant \inmodule QtGui
int height() const
Returns the height of the font.
static QClipboard * clipboard()
Returns the object for interacting with the clipboard.
static QInputMethod * inputMethod()
returns the input method.
The QKeyEvent class describes a key event.
static constexpr Policy Preferred
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void translate(const QVector3D &vector)
Multiplies this matrix by another that translates coordinates by the components of vector.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
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
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
The QQmlComponent class encapsulates a QML component definition.
The QQmlContext class defines a context within a QML engine.
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to \l{QFile}.
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
static bool isEventFromMouseOrTouchpad(const QPointerEvent *ev)
virtual bool transformChanged(QQuickItem *transformedItem)
QSGRenderContext * sceneGraphRenderContext() const
QSGContext * sceneGraphContext() const
void setSizePolicy(const QLayoutPolicy::Policy &horizontalPolicy, const QLayoutPolicy::Policy &verticalPolicy)
virtual void implicitWidthChanged()
QQuickAnchorLine baseline() 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.
QQuickItem * viewportItem() const
If the \l ItemObservesViewport flag is set, returns the nearest parent with the \l ItemIsViewport fla...
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.
bool hasActiveFocus() const
virtual void mousePressEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
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.
bool heightValid() const
Returns whether the height property has been set explicitly.
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 widthValid() const
Returns whether the width property has been set explicitly.
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key release events for an item.
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.
friend class QQuickAccessibleAttached
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 setTextInteractionFlags(Qt::TextInteractionFlags flags)
void linkHovered(const QString &link)
virtual void processEvent(QEvent *e, const QTransform &transform)
void setAcceptRichText(bool accept)
void markerHovered(bool marker)
QTextCursor textCursor() const
void setCursorIsFocusIndicator(bool b)
void setCursorVisible(bool visible)
static QQuickTextDocumentPrivate * get(QQuickTextDocument *doc)
\qmltype TextDocument \instantiates QQuickTextDocument \inqmlmodule QtQuick
Status status
the status of document loading or saving
QList< Node >::iterator TextNodeIterator
QQuickTextEdit::HAlignment hAlign
QList< Node > textNodeMap
void setImplicitResizeEnabled(bool enabled)
bool isImplicitResizeEnabled() const
void setRightPadding(qreal value, bool reset=false)
QLazilyAllocated< ExtraData > extra
Qt::LayoutDirection textDirection(const QString &text) const
Qt::LayoutDirection contentDirection
bool setHAlign(QQuickTextEdit::HAlignment, bool forceAlign=false)
void onDocumentStatusChanged()
static const int largeTextSizeThreshold
QQuickTextControl * control
qreal getImplicitWidth() const override
void setLeftPadding(qreal value, bool reset=false)
void updateDefaultTextOption()
QSGInternalTextNode * createTextNode()
QQuickTextDocument * quickDocument
void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QSGInternalTextNode *, TextNodeIterator &, int startPos)
QQuickTextEdit::WrapMode wrapMode
bool transformChanged(QQuickItem *transformedItem) override
QQuickTextEdit::VAlignment vAlign
void handleFocusEvent(QFocusEvent *event)
QQuickTextEdit::RenderType renderType
void setBottomPadding(qreal value, bool reset=false)
bool determineHorizontalAlignment()
void setTopPadding(qreal value, bool reset=false)
bool isLinkHoveredConnected()
bool requireImplicitWidth
void mirrorChange() override
void setFont(const QFont &font)
void setRenderType(RenderType renderType)
void selectWord()
\qmlmethod QtQuick::TextEdit::selectWord()
void resetBottomPadding()
void keyReleaseEvent(QKeyEvent *) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setInputMethodHints(Qt::InputMethodHints hints)
void setWrapMode(WrapMode w)
bool isInputMethodComposing() const
\qmlproperty bool QtQuick::TextEdit::inputMethodComposing
void inputMethodComposingChanged()
void setCursorDelegate(QQmlComponent *)
void focusInEvent(QFocusEvent *event) override
This event handler can be reimplemented in a subclass to receive focus-in events for an item.
void hoverMoveEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-move events for an item.
void setPersistentSelection(bool on)
void setSelectionColor(const QColor &c)
void setFocusOnPress(bool on)
SelectionMode mouseSelectionMode
void invalidate() override
void keyPressEvent(QKeyEvent *) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
QQuickTextDocument * textDocument
\qmlproperty TextDocument QtQuick::TextEdit::textDocument
HAlignment hAlign() const
\qmlproperty enumeration QtQuick::TextEdit::horizontalAlignment \qmlproperty enumeration QtQuick::Tex...
void mouseMoveEvent(QMouseEvent *event) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
int resourcesLoading() const
void remove(int start, int end)
\qmlmethod string QtQuick::TextEdit::remove(int start, int end)
QQuickTextSelection * cursorSelection
void setSelectByMouse(bool)
void setColor(const QColor &c)
void setMouseSelectionMode(SelectionMode mode)
QRectF clipRect() const override
Returns the rectangular area within this item that is currently visible in \l viewportItem(),...
bool event(QEvent *) override
\reimp
void componentComplete() override
Ensures any delayed caching or data loading the class needs to performed is complete.
void setRightPadding(qreal padding)
Qt::InputMethodHints inputMethodHints
void hoverLeaveEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
Q_INVOKABLE int positionAt(qreal x, qreal y) const
\qmlmethod int QtQuick::TextEdit::positionAt(int x, int y)
bool focusOnPress() const
\qmlproperty bool QtQuick::TextEdit::activeFocusOnPress
void select(int start, int end)
\qmlmethod QtQuick::TextEdit::select(int start, int end)
void setLeftPadding(qreal padding)
void selectAll()
\qmlmethod QtQuick::TextEdit::selectAll()
void activeFocusOnPressChanged(bool activeFocusOnPressed)
void setOverwriteMode(bool overwrite)
void setHAlign(HAlignment align)
void selectedTextColorChanged(const QColor &color)
void setTopPadding(qreal padding)
void setCursorPosition(int pos)
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
void mouseReleaseEvent(QMouseEvent *event) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setPadding(qreal padding)
void insert(int position, const QString &text)
\qmlmethod QtQuick::TextEdit::insert(int position, string text)
void setTextFormat(TextFormat format)
void mouseDoubleClickEvent(QMouseEvent *event) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void textMarginChanged(qreal textMargin)
void inputMethodHintsChanged()
void updatePolish() override
This function should perform any layout as required for this item.
~QQuickTextEdit() override
void readOnlyChanged(bool isReadOnly)
Q_INVOKABLE QString getFormattedText(int start, int end) const
\qmlmethod string QtQuick::TextEdit::getFormattedText(int start, int end)
QQmlComponent * cursorDelegate
void setTabStopDistance(qreal distance)
VAlignment vAlign() const
void verticalAlignmentChanged(QQuickTextEdit::VAlignment alignment)
void setSelectedTextColor(const QColor &c)
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
void cursorVisibleChanged(bool isCursorVisible)
void mousePressEvent(QMouseEvent *event) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void hoverEnterEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
Q_INVOKABLE QString getText(int start, int end) const
\qmlmethod string QtQuick::TextEdit::getText(int start, int end)
void setBottomPadding(qreal padding)
bool isRightToLeft(int start, int end)
\qmlmethod QtQuick::TextEdit::isRightToLeft(int start, int end)
void selectByMouseChanged(bool selectByMouse)
void setReadOnly(bool)
\qmlproperty bool QtQuick::TextEdit::readOnly
void setSelectByKeyboard(bool)
void deselect()
\qmlmethod QtQuick::TextEdit::deselect()
void fontChanged(const QFont &font)
bool isCursorVisible() const
\qmlproperty bool QtQuick::TextEdit::cursorVisible If true the text edit shows a cursor.
void selectionColorChanged(const QColor &color)
void undo()
\qmlmethod QtQuick::TextEdit::undo()
QQuickTextEdit(QQuickItem *parent=nullptr)
void mouseSelectionModeChanged(QQuickTextEdit::SelectionMode mode)
void focusOutEvent(QFocusEvent *event) override
This event handler can be reimplemented in a subclass to receive focus-out events for an item.
void textFormatChanged(QQuickTextEdit::TextFormat textFormat)
void setVAlign(VAlignment align)
QRectF boundingRect() const override
Returns the extents of the item in its own coordinate system: a rectangle from {0,...
void setBaseUrl(const QUrl &url)
QString preeditText
\qmlproperty string QtQuick::TextEdit::preeditText \readonly
void setTextMargin(qreal margin)
Q_INVOKABLE QRectF positionToRectangle(int) const
\qmlmethod rectangle QtQuick::TextEdit::positionToRectangle(position)
HAlignment effectiveHAlign() const
void redo()
\qmlmethod QtQuick::TextEdit::redo()
void setCursorVisible(bool on)
Q_INVOKABLE void moveCursorSelection(int pos)
\qmlmethod QtQuick::TextEdit::moveCursorSelection(int position, SelectionMode mode)
void persistentSelectionChanged(bool isPersistentSelection)
void setText(const QString &)
\qmlproperty string QtQuick::TextEdit::font.family
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
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)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
bool intersects(const QRectF &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e.
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
virtual QSGInternalTextNode * createInternalTextNode(QSGRenderContext *renderContext)
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.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
void appendChildNode(QSGNode *node)
Appends node to this node's list of children.
QSGNode * parent() const
Returns the parent node of this node.
void setFlag(Flag, bool=true)
Sets the flag f on this node if enabled is true; otherwise clears the flag.
RenderType
This enum type describes type of glyph node used for rendering the text.
\macro QT_RESTRICTED_CAST_FROM_ASCII
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.
bool isRightToLeft() const
Returns true if the string is read right to left.
int length() const
Returns the length of the block in characters.
const QTextDocument * document() const
Returns the text document this text block belongs to, or \nullptr if the text block does not belong t...
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block's contents.
int position() const
Returns the index of the block's first character within the document.
QString text() const
Returns the block's contents as plain text.
\reentrant \inmodule QtGui
QTextBlock block() const
Returns the block that contains the cursor.
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
\reentrant \inmodule QtGui
void setModified(bool m=true)
ResourceType
This enum describes the types of resources that can be loaded by QTextDocument's loadResource() funct...
void contentsChange(int from, int charsRemoved, int charsAdded)
This signal is emitted whenever the document's content changes; for example, when text is inserted or...
void setDefaultTextOption(const QTextOption &option)
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QTextOption defaultTextOption() const
the default text option will be set on all \l{QTextLayout}s in the document.
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
void setUndoRedoEnabled(bool enable)
void setDocumentMargin(qreal margin)
QTextBlock firstBlock() const
void resetFontEngineCache()
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
QTextEngine * engine() const
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
QString preeditAreaText() const
Returns the text that is inserted in the layout before editing occurs.
QRectF boundingRect() const
The smallest rectangle that contains all the lines in the layout.
qreal ascent() const
Returns the line's ascent.
WrapMode
This enum describes how text is wrapped in a document.
void setTabStopDistance(qreal tabStopDistance)
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
void textChanged(const QString &newText)
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ ImInputItemClipRectangle
@ TextSelectableByKeyboard
Q_GUI_EXPORT bool mightBeRichText(QAnyStringView)
Returns true if the string text is likely to be rich text; otherwise returns false.
@ ActiveWindowFocusReason
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
int qRound(qfloat16 d) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
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)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLsizei GLsizei GLfloat distance
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
QQmlContext * qmlContext(const QObject *obj)
#define qmlobject_connect(Sender, SenderType, Signal, Receiver, ReceiverType, Method)
Connect Signal of Sender to Method of Receiver.
#define IS_SIGNAL_CONNECTED(Sender, SenderType, Name, Arguments)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static const int nodeBreakingSize
\qmlsignal QtQuick::TextEdit::linkActivated(string link)
#define QQUICKTEXT_LARGETEXT_THRESHOLD
static bool operator<(const TextNode &n1, const TextNode &n2)
static void updateNodeTransform(QSGInternalTextNode *node, const QPointF &topLeft)
QQuickTextEditPrivate::Node TextNode
void resetEngine(QQuickTextNodeEngine *engine, const QColor &textColor, const QColor &selectedTextColor, const QColor &selectionColor)
QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickTextEditPrivate::Node &)
QUrl url("example.com")
[constructor-url-reference]
item setCursor(Qt::IBeamCursor)
[1]
view viewport() -> scroll(dx, dy, deviceRect)