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>
39using namespace
Qt::StringLiterals;
102#if !defined(QQUICKTEXT_LARGETEXT_THRESHOLD)
103 #define QQUICKTEXT_LARGETEXT_THRESHOLD 10000
112 RootNode() : cursorNode(
nullptr), frameDecorationsNode(
nullptr)
117 if (frameDecorationsNode) {
118 removeChildNode(frameDecorationsNode);
119 delete frameDecorationsNode;
121 frameDecorationsNode = newNode;
128 removeChildNode(cursorNode);
130 cursorNode = newNode;
132 appendChildNode(cursorNode);
168#if QT_CONFIG(texthtmlparser)
170 d->text =
d->control->toHtml();
173#if QT_CONFIG(textmarkdownwriter)
175 d->text =
d->control->toMarkdown();
178 d->text =
d->control->toPlainText();
179 d->textCached =
true;
430 }
else if (
d->richText) {
431#if QT_CONFIG(texthtmlparser)
432 d->control->setHtml(
text);
434 d->control->setPlainText(
text);
436 }
else if (
d->markdownText) {
437 d->control->setMarkdownText(
text);
439 d->control->setPlainText(
text);
449void QQuickTextEdit::q_invalidate()
453 if (
d->document !=
nullptr)
454 d->document->markContentsDirty(0,
d->document->characterCount());
455 invalidateFontCaches();
476 return d->control->preeditText();
545 auto mightBeRichText = [
this]() {
549 auto findSourceFormat = [
d, mightBeRichText](
Qt::TextFormat detectedFormat) {
554 if (detectedFormat ==
Qt::AutoText && mightBeRichText())
570 bool textCachedChanged =
false;
571 bool converted =
false;
575 if (
d->quickDocument) {
581 const TextFormat sourceFormat = findSourceFormat(detectedFormat);
582 const TextFormat destinationFormat = findDestinationFormat(detectedFormat, sourceFormat);
584 d->richText = destinationFormat ==
RichText;
589 d->textCached =
false;
590 textCachedChanged =
true;
593 switch (destinationFormat) {
595#if QT_CONFIG(texthtmlparser)
600 d->control->setPlainText(
d->textCached ?
d->text :
d->control->toHtml());
604#if QT_CONFIG(textmarkdownwriter) && QT_CONFIG(textmarkdownreader)
609 d->control->setPlainText(
d->textCached ?
d->text :
d->control->toMarkdown());
615#if QT_CONFIG(texthtmlparser)
616 switch (sourceFormat) {
619 d->control->setHtml(
d->control->toHtml());
625 d->control->setHtml(
d->textCached ?
d->text :
d->control->toPlainText());
635#if QT_CONFIG(textmarkdownwriter) && QT_CONFIG(textmarkdownreader)
636 switch (sourceFormat) {
639 d->control->setMarkdownText(
d->control->toMarkdown());
645 d->control->setMarkdownText(
d->textCached ?
d->text :
d->control->toPlainText());
666 <<
"rich?" <<
d->richText <<
"md?" <<
d->markdownText
667 <<
"converted?" << converted <<
"cache invalidated?" << textCachedChanged;
670 d->control->setAcceptRichText(
d->format !=
PlainText);
672 if (textCachedChanged)
704 return d->renderType;
715 d->updateDefaultTextOption();
724 return d->sourceFont;
730 if (
d->sourceFont ==
font)
733 d->sourceFont =
font;
736 if (
d->font.pointSizeF() != -1) {
739 d->font.setPointSizeF(
size/2.0);
742 if (oldFont !=
d->font) {
743 d->document->setDefaultFont(
d->font);
746 moveCursorDelegate();
749 updateWholeDocument();
785 updateWholeDocument();
797 return d->selectionColor;
803 if (
d->selectionColor ==
color)
806 d->selectionColor =
color;
807 updateWholeDocument();
819 return d->selectedTextColor;
825 if (
d->selectedTextColor ==
color)
828 d->selectedTextColor =
color;
829 updateWholeDocument();
876 d->updateDefaultTextOption();
878 updateWholeDocument();
885 d->hAlignImplicit =
true;
887 d->updateDefaultTextOption();
896 if (!
d->hAlignImplicit &&
d->effectiveLayoutMirror) {
908 return effectiveAlignment;
914 if (
hAlign == align && !forceAlign)
918 const auto oldEffectiveHAlign =
q->effectiveHAlign();
923 emit q->horizontalAlignmentChanged(align);
926 if (
q->effectiveHAlign() != oldEffectiveHAlign) {
927 emit q->effectiveHorizontalAlignmentChanged();
931 if (forceAlign && wasImplicit) {
934 emit q->effectiveHorizontalAlignmentChanged();
942 while (!character->isNull()) {
943 switch (character->direction()) {
984 if (
q->isComponentComplete()) {
988 emit q->effectiveHorizontalAlignmentChanged();
996 qCDebug(lcVP) <<
q <<
"sees that" << transformedItem <<
"moved in VP" <<
q->clipRect();
1005 qCDebug(lcVP) <<
"viewport" << vp <<
"now goes beyond rendered region" <<
renderedRegion <<
"; updating";
1006 q->updateWholeDocument();
1019Qt::InputMethodHints QQuickTextEditPrivate::effectiveInputMethodHints()
const
1025#if QT_CONFIG(accessibility)
1026void QQuickTextEditPrivate::accessibilityActiveChanged(
bool active)
1032 if (QQuickAccessibleAttached *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(
1033 qmlAttachedPropertiesObject<QQuickAccessibleAttached>(
q,
true))) {
1034 accessibleAttached->setRole(effectiveAccessibleRole());
1035 accessibleAttached->set_readOnly(
q->isReadOnly());
1039QAccessible::Role QQuickTextEditPrivate::accessibleRole()
const
1041 return QAccessible::EditableText;
1048 qreal oldPadding =
q->topPadding();
1055 q->updateWholeDocument();
1056 emit q->topPaddingChanged();
1063 qreal oldPadding =
q->leftPadding();
1070 q->updateWholeDocument();
1071 emit q->leftPaddingChanged();
1078 qreal oldPadding =
q->rightPadding();
1085 q->updateWholeDocument();
1086 emit q->rightPaddingChanged();
1093 qreal oldPadding =
q->bottomPadding();
1100 q->updateWholeDocument();
1101 emit q->bottomPaddingChanged();
1130 d->updateDefaultTextOption();
1132 moveCursorDelegate();
1165 if (
mode ==
d->wrapMode)
1168 d->updateDefaultTextOption();
1181 return d->lineCount;
1200 return qMax(0,
d->document->characterCount() - 1);
1212 return d->contentSize.width();
1224 return d->contentSize.height();
1239 if (
d->baseUrl.isEmpty()) {
1252 d->document->setBaseUrl(
url);
1277 return d->control->cursorRect(
c).translated(
d->xoff,
d->yoff);
1303 const int preeditLength =
layout
1304 ?
layout->preeditAreaText().size()
1306 if (preeditLength > 0
1307 &&
d->document->documentLayout()->blockBoundingRect(
cursor.block()).contains(
x,
y)) {
1308 r =
r >
cursor.position() + preeditLength
1330 if (!
d->cursorSelection)
1332 return d->cursorSelection;
1379 d->control->setTextCursor(
cursor);
1428 d->control->setTextCursor(
cursor);
1441 return d->cursorVisible;
1447 if (
d->cursorVisible == on)
1449 d->cursorVisible = on;
1452 if (!on && !
d->persistentSelection)
1453 d->control->setCursorIsFocusIndicator(
true);
1454 d->control->setCursorVisible(on);
1473 return d->control->textCursor().position();
1479 if (pos < 0 || pos >=
d->document->characterCount())
1485 d->control->setTextCursor(
cursor);
1486 d->control->updateCursorRectangle(
true);
1505 return d->cursorComponent;
1514void QQuickTextEdit::createCursor()
1517 d->cursorPending =
true;
1534 return d->control->textCursor().selectionStart();
1550 return d->control->textCursor().selectionEnd();
1570#if QT_CONFIG(texthtmlparser)
1571 return d->richText ||
d->markdownText
1572 ?
d->control->textCursor().selectedText()
1573 :
d->control->textCursor().selection().toPlainText();
1575 return d->control->textCursor().selection().toPlainText();
1588 return d->focusOnPress;
1594 if (
d->focusOnPress == on)
1596 d->focusOnPress = on;
1609 return d->persistentSelection;
1615 if (
d->persistentSelection == on)
1617 d->persistentSelection = on;
1629 return d->textMargin;
1635 if (
d->textMargin == margin)
1637 d->textMargin = margin;
1638 d->document->setDocumentMargin(
d->textMargin);
1685 return d->inputMethodHints;
1696 if (hints ==
d->inputMethodHints)
1699 d->inputMethodHints = hints;
1708 if (!
d->inLayout && ((newGeometry.
width() != oldGeometry.
width())
1711 updateWholeDocument();
1713 moveCursorDelegate();
1729 updateWholeDocument();
1750 d->document->setBaseUrl(context ? context->resolvedUrl(
url) :
url);
1751 if (!
d->text.isEmpty()) {
1752#if QT_CONFIG(texthtmlparser)
1754 d->control->setHtml(
d->text);
1757#if QT_CONFIG(textmarkdownreader)
1758 if (
d->markdownText)
1759 d->control->setMarkdownText(
d->text);
1762 d->control->setPlainText(
d->text);
1766 d->determineHorizontalAlignment();
1767 d->updateDefaultTextOption();
1775#if QT_CONFIG(accessibility)
1776 if (QAccessible::isActive())
1777 d->accessibilityActiveChanged(
true);
1784 return d->pixmapsInProgress.size();
1804 if (
d->selectByKeyboardSet)
1805 return d->selectByKeyboard;
1813 if (!
d->selectByKeyboardSet || was != on) {
1814 d->selectByKeyboardSet =
true;
1815 d->selectByKeyboard = on;
1820 emit selectByKeyboardChanged(on);
1850 return d->selectByMouse;
1856 if (
d->selectByMouse == on)
1859 d->selectByMouse = on;
1866#if QT_CONFIG(cursor)
1867 d->updateMouseCursorShape();
1885 return d->mouseSelectionMode;
1891 if (
d->mouseSelectionMode !=
mode) {
1892 d->mouseSelectionMode =
mode;
1913 setFlag(QQuickItem::ItemAcceptsInputMethod, !
r);
1916 if (
d->selectByMouse)
1918 if (
d->selectByKeyboardSet &&
d->selectByKeyboard)
1920 else if (!
d->selectByKeyboardSet && !
r)
1924 d->control->setTextInteractionFlags(
flags);
1930#if QT_CONFIG(cursor)
1931 d->updateMouseCursorShape();
1933 q_canPasteChanged();
1935 if (!
d->selectByKeyboardSet)
1936 emit selectByKeyboardChanged(!
r);
1943#if QT_CONFIG(accessibility)
1944 if (QAccessible::isActive()) {
1946 accessibleAttached->set_readOnly(
r);
1970 return d->control->cursorRect().translated(
d->xoff,
d->yoff);
1978 if (
event->isAccepted())
2001 return d->control->overwriteMode();
2007 d->control->setOverwriteMode(overwrite);
2018 if (!
event->isAccepted())
2030 if (!
event->isAccepted())
2044 d->control->setTextCursor(
c);
2055 d->control->selectAll();
2068 d->control->setTextCursor(
c);
2087 if (
start < 0 || end < 0 || start >=
d->document->characterCount() ||
end >=
d->document->characterCount())
2094 d->control->setTextCursor(
cursor);
2099 updateInputMethod();
2112 qmlWarning(
this) <<
"isRightToLeft(start, end) called with the end property being smaller than the start.";
2119#if QT_CONFIG(clipboard)
2125void QQuickTextEdit::cut()
2136void QQuickTextEdit::copy()
2147void QQuickTextEdit::paste()
2150 d->control->paste();
2191 if (
d->focusOnPress){
2197 qGuiApp->inputMethod()->show();
2202 if (!
event->isAccepted())
2215 if (!
event->isAccepted())
2227 if (!
event->isAccepted())
2239 if (!
event->isAccepted())
2269 v = (bool)(
flags() & ItemAcceptsInputMethod);
2272 v = (int)
d->effectiveInputMethodHints();
2275 v = QQuickItem::inputMethodQuery(
property);
2285 v =
QVariant(
v.toRectF().translated(
d->xoff,
d->yoff));
2301void QQuickTextEdit::triggerPreprocess()
2329 auto existingJobIter = std::find_if(
2330 d->pixmapsInProgress.cbegin(),
d->pixmapsInProgress.cend(),
2331 [&
url](
const auto *job) { return job->url() == url; } );
2332 if (existingJobIter !=
d->pixmapsInProgress.cend()) {
2336 d->pixmapsInProgress.erase(existingJobIter);
2340 qCDebug(lcTextEdit) <<
"already downloading" <<
url;
2353 p->connectFinished(
this,
SLOT(resourceRequestFinished()));
2354 d->pixmapsInProgress.append(
p);
2356 return p->isReady() ?
p->image() :
QVariant();
2362void QQuickTextEdit::resourceRequestFinished()
2365 for (
auto it =
d->pixmapsInProgress.cbegin();
it !=
d->pixmapsInProgress.cend(); ++
it) {
2369 qCDebug(lcTextEdit) <<
"failed to load (error)" << job->
url();
2378 qCDebug(lcTextEdit) << (
res.isValid() ?
"done downloading" :
"failed to load") << job->
url() << job->
rect();
2379 d->pixmapsInProgress.erase(
it);
2384 if (
d->pixmapsInProgress.isEmpty()) {
2396 return n1.startPos() < n2.startPos();
2412void QQuickTextEdit::invalidateFontCaches()
2415 if (
d->document ==
nullptr)
2419 for (block =
d->document->firstBlock(); block.
isValid(); block = block.
next()) {
2434 if (
d->ownsDocument)
2437 d->ownsDocument =
false;
2438 d->control->setDocument(doc);
2445 engine->setTextColor(textColor);
2446 engine->setSelectedTextColor(selectedTextColor);
2447 engine->setSelectionColor(selectionColor);
2457 && oldNode !=
nullptr) {
2469 d->textNodeMap.clear();
2474 RootNode *rootNode =
static_cast<RootNode *
>(oldNode);
2476 std::optional<int> firstPosAcrossAllNodes;
2477 if (nodeIterator !=
d->textNodeMap.end())
2478 firstPosAcrossAllNodes = nodeIterator->startPos();
2480 while (nodeIterator !=
d->textNodeMap.end() && !nodeIterator->dirty())
2486 if (!oldNode || nodeIterator < d->textNodeMap.end() ||
d->textNodeMap.isEmpty()) {
2489 rootNode =
new RootNode;
2491 int firstDirtyPos = 0;
2492 if (nodeIterator !=
d->textNodeMap.end()) {
2493 firstDirtyPos = nodeIterator->startPos();
2497 auto it =
d->textNodeMap.constEnd();
2498 while (
it != nodeIterator) {
2502 firstCleanNode =
it->textNode();
2505 rootNode->removeChildNode(nodeIterator->textNode());
2506 delete nodeIterator->textNode();
2507 nodeIterator =
d->textNodeMap.erase(nodeIterator);
2508 }
while (nodeIterator !=
d->textNodeMap.constEnd() && nodeIterator->textNode() != firstCleanNode);
2519 rootNode->resetFrameDecorations(
d->createTextNode());
2520 resetEngine(&frameDecorationsEngine,
d->color,
d->selectedTextColor,
d->selectionColor);
2524 int currentNodeSize = 0;
2525 int nodeStart = firstDirtyPos;
2528 basePositionMatrix.
translate(basePosition.x(), basePosition.y());
2529 rootNode->setMatrix(basePositionMatrix);
2532 const TextNode firstCleanNode = (nodeIterator !=
d->textNodeMap.end()) ? *nodeIterator
2535 QList<QTextFrame *> frames;
2536 frames.append(
d->document->rootFrame());
2539 d->firstBlockInViewport = -1;
2540 d->firstBlockPastViewport = -1;
2541 int frameCount = -1;
2542 while (!frames.isEmpty()) {
2547 qCDebug(lcVP) <<
"frame" << frameCount << textFrame
2550 frames.append(textFrame->childFrames());
2551 frameDecorationsEngine.addFrameDecorations(
d->document, textFrame);
2554 if (textFrame->firstPosition() > textFrame->lastPosition()
2556 node =
d->createTextNode();
2557 updateNodeTransform(node,
d->document->documentLayout()->frameBoundingRect(textFrame).topLeft());
2558 const int pos = textFrame->firstPosition() - 1;
2561 QTextBlock block = textFrame->firstCursorPosition().block();
2562 nodeOffset =
d->document->documentLayout()->blockBoundingRect(block).topLeft();
2566 inView = coveredRegion.bottom() >=
viewport.top() && coveredRegion.top() <=
viewport.bottom();
2567 qCDebug(lcVP) <<
"non-flow frame" << coveredRegion <<
"in viewport?" << inView;
2572 pos, textFrame->frameFormat().position());
2577 QList<int> frameBoundaries;
2578 frameBoundaries.reserve(frames.size());
2580 frameBoundaries.append(
frame->firstPosition());
2581 std::sort(frameBoundaries.begin(), frameBoundaries.end());
2584 while (!
it.atEnd()) {
2586 if (block.
position() < firstDirtyPos) {
2591 if (!
engine.hasContents())
2592 nodeOffset =
d->document->documentLayout()->blockBoundingRect(block).topLeft();
2599 inView = coveredRegion.bottom() >
viewport.top();
2601 const bool potentiallyScrollingBackwards = firstPosAcrossAllNodes && *firstPosAcrossAllNodes == firstDirtyPos;
2602 if (
d->firstBlockInViewport < 0 && inView && potentiallyScrollingBackwards) {
2604 if (coveredRegion.top() >
viewport.top() + 1) {
2605 qCDebug(lcVP) <<
"checking backwards from block" << block.
blockNumber() <<
"@" << nodeOffset.y() << coveredRegion;
2606 while (
it != textFrame->
begin() &&
it.currentBlock().layout() &&
2607 it.currentBlock().layout()->boundingRect().top() + nodeOffset.y() >
viewport.top()) {
2608 nodeOffset =
d->document->documentLayout()->blockBoundingRect(
it.currentBlock()).topLeft();
2611 if (!
it.currentBlock().layout())
2614 block =
it.currentBlock();
2616 firstDirtyPos =
it.currentBlock().position();
2618 qCWarning(lcVP) <<
"failed to find a text block with layout during back-scrolling";
2621 qCDebug(lcVP) <<
"first block in viewport" << block.
blockNumber() <<
"@" << nodeOffset.y() << coveredRegion;
2623 d->renderedRegion = coveredRegion;
2625 if (nodeOffset.y() >
viewport.bottom()) {
2627 if (
d->firstBlockInViewport >= 0 &&
d->firstBlockPastViewport < 0) {
2629 <<
"@" << nodeOffset.y() <<
"total region rendered" <<
d->renderedRegion;
2634 if (inView && !block.
text().
isEmpty() && coveredRegion.isValid()) {
2635 d->renderedRegion =
d->renderedRegion.united(coveredRegion);
2638 if (!frames.isEmpty())
2642 if (inView &&
d->firstBlockInViewport < 0)
2646 bool createdNodeInView =
false;
2648 if (!
engine.hasContents()) {
2649 if (node && !node->
parent())
2650 d->addCurrentTextNodeToRoot(&
engine, rootNode, node, nodeIterator, nodeStart);
2651 node =
d->createTextNode();
2652 createdNodeInView =
true;
2657 currentNodeSize += block.
length();
2660 if ((
it.atEnd()) || block.
next().
position() >= firstCleanNode.startPos())
2663 if (node && (currentNodeSize >
nodeBreakingSize || lowerBound == frameBoundaries.constEnd() || *lowerBound > nodeStart)) {
2664 currentNodeSize = 0;
2666 d->addCurrentTextNodeToRoot(&
engine, rootNode, node, nodeIterator, nodeStart);
2667 if (!createdNodeInView)
2668 node =
d->createTextNode();
2676 d->addCurrentTextNodeToRoot(&
engine, rootNode, node, nodeIterator, nodeStart);
2680 rootNode->prependChildNode(rootNode->frameDecorationsNode);
2682 Q_ASSERT(nodeIterator ==
d->textNodeMap.end()
2683 || (nodeIterator->textNode() == firstCleanNode.textNode()
2684 && nodeIterator->startPos() == firstCleanNode.startPos()));
2686 if (firstCleanNode.textNode() !=
nullptr) {
2687 QPointF oldOffset = firstCleanNode.textNode()->matrix().map(
QPointF(0,0));
2688 QPointF currentOffset =
d->document->documentLayout()->blockBoundingRect(
2689 d->document->findBlock(firstCleanNode.startPos())).topLeft();
2690 QPointF delta = currentOffset - oldOffset;
2691 while (nodeIterator !=
d->textNodeMap.end()) {
2702 std::sort(
d->textNodeMap.begin(),
d->textNodeMap.end());
2705 if (
d->cursorComponent ==
nullptr) {
2707 if (!
isReadOnly() &&
d->cursorVisible &&
d->control->cursorOn() &&
d->control->cursorVisible())
2708 cursor =
d->sceneGraphContext()->createInternalRectangleNode(
d->control->cursorRect(),
d->color);
2709 rootNode->resetCursorNode(
cursor);
2712 invalidateFontCaches();
2719 invalidateFontCaches();
2731 if (!
d->canPasteValid) {
2748 return d->document->isUndoAvailable();
2761 return d->document->isRedoAvailable();
2782 return d->control->hasImState();
2787 : explicitTopPadding(
false)
2788 , explicitLeftPadding(
false)
2789 , explicitRightPadding(
false)
2790 , explicitBottomPadding(
false)
2791 , implicitResize(true)
2799#if QT_CONFIG(clipboard)
2807 q->setFlag(QQuickItem::ItemAcceptsInputMethod);
2811 q->setAcceptHoverEvents(
true);
2822 q->setKeepMouseGrab(
true);
2834#if QT_CONFIG(clipboard)
2851#if QT_CONFIG(cursor)
2852 updateMouseCursorShape();
2860 if (!
q->isReadOnly() &&
q->hasActiveFocus() &&
qGuiApp)
2864void QQuickTextEdit::q_textChanged()
2867 d->textCached =
false;
2869 d->contentDirection =
d->textDirection(
it.text());
2873 d->determineHorizontalAlignment();
2874 d->updateDefaultTextOption();
2877 markDirtyNodesForRange(0,
d->document->characterCount(), 0);
2878 if (isComponentComplete()) {
2887void QQuickTextEdit::markDirtyNodesForRange(
int start,
int end,
int charDelta)
2901 if (
it != textNodeMapBegin) {
2904 it = std::lower_bound(textNodeMapBegin, textNodeMapEnd, otherDummy);
2908 while (
it != textNodeMapEnd) {
2909 if (
it->startPos() <=
end)
2912 it->moveStartPos(charDelta);
2919void QQuickTextEdit::q_contentsChange(
int pos,
int charsRemoved,
int charsAdded)
2923 const int editRange =
pos +
qMax(charsAdded, charsRemoved);
2924 const int delta = charsAdded - charsRemoved;
2926 markDirtyNodesForRange(
pos, editRange, delta);
2928 if (isComponentComplete()) {
2935void QQuickTextEdit::moveCursorDelegate()
2939 updateInputMethod();
2941 emit cursorRectangleChanged();
2944 QRectF cursorRect = cursorRectangle();
2945 d->cursorItem->setX(cursorRect.
x());
2946 d->cursorItem->setY(cursorRect.
y());
2947 d->cursorItem->setHeight(cursorRect.
height());
2950void QQuickTextEdit::updateSelection()
2955 if (
d->control->textCursor().hasSelection() ||
d->hadSelection) {
2956 markDirtyNodesForRange(
qMin(
d->lastSelectionStart,
d->control->textCursor().selectionStart()),
qMax(
d->control->textCursor().selectionEnd(),
d->lastSelectionEnd), 0);
2957 if (isComponentComplete()) {
2964 d->hadSelection =
d->control->textCursor().hasSelection();
2966 if (
d->lastSelectionStart !=
d->control->textCursor().selectionStart()) {
2967 d->lastSelectionStart =
d->control->textCursor().selectionStart();
2968 emit selectionStartChanged();
2970 if (
d->lastSelectionEnd !=
d->control->textCursor().selectionEnd()) {
2971 d->lastSelectionEnd =
d->control->textCursor().selectionEnd();
2972 emit selectionEndChanged();
2982 d->contentSize.width(),
2983 d->contentSize.height());
2985 int cursorWidth = 1;
2988 else if (!
d->document->isEmpty())
2992 r.setRight(
r.right() + cursorWidth);
3001 int cursorWidth = 1;
3003 cursorWidth =
d->cursorItem->width();
3004 if (!
d->document->isEmpty())
3009 r.setRight(
r.right() + cursorWidth);
3027void QQuickTextEdit::updateSize()
3030 if (!isComponentComplete()) {
3038 if (!
d->requireImplicitWidth) {
3041 if (
d->requireImplicitWidth)
3044 if (
d->requireImplicitWidth) {
3045 d->document->setTextWidth(-1);
3046 const qreal naturalWidth =
d->document->idealWidth();
3047 const bool wasInLayout =
d->inLayout;
3049 if (
d->isImplicitResizeEnabled())
3050 setImplicitWidth(naturalWidth + leftPadding() + rightPadding());
3051 d->inLayout = wasInLayout;
3055 const qreal newTextWidth =
width() - leftPadding() - rightPadding();
3056 if (
d->document->textWidth() != newTextWidth)
3057 d->document->setTextWidth(newTextWidth);
3058 }
else if (
d->wrapMode == NoWrap) {
3062 const qreal newTextWidth =
d->document->idealWidth();
3063 if (
d->document->textWidth() != newTextWidth)
3064 d->document->setTextWidth(newTextWidth);
3066 d->document->setTextWidth(-1);
3073 if (
d->isImplicitResizeEnabled()) {
3076 setImplicitSize(newWidth + leftPadding() + rightPadding(), newHeight + topPadding() + bottomPadding());
3078 setImplicitHeight(newHeight + topPadding() + bottomPadding());
3088 if (firstLine.isValid())
3092 setBaselineOffset(
baseline +
d->yoff +
d->textMargin);
3095 if (
d->contentSize !=
size) {
3096 d->contentSize =
size;
3098 const bool wasInResize =
d->inResize;
3101 emit contentSizeChanged();
3102 d->inResize = wasInResize;
3107void QQuickTextEdit::updateWholeDocument()
3110 if (!
d->textNodeMap.isEmpty()) {
3115 if (isComponentComplete()) {
3122void QQuickTextEdit::invalidateBlock(
const QTextBlock &block)
3127 if (isComponentComplete()) {
3134void QQuickTextEdit::updateCursor()
3137 if (isComponentComplete() &&
isVisible()) {
3144void QQuickTextEdit::q_linkHovered(
const QString &link)
3147 emit linkHovered(link);
3148#if QT_CONFIG(cursor)
3150 d->updateMouseCursorShape();
3157void QQuickTextEdit::q_markerHovered(
bool hovered)
3160#if QT_CONFIG(cursor)
3162 d->updateMouseCursorShape();
3169void QQuickTextEdit::q_updateAlignment()
3172 if (
d->determineHorizontalAlignment()) {
3173 d->updateDefaultTextOption();
3175 moveCursorDelegate();
3179void QQuickTextEdit::updateTotalLines()
3189 subLines +=
layout->lineCount()-1;
3192 int newTotalLines =
d->document->lineCount() + subLines;
3193 if (
d->lineCount != newTotalLines) {
3194 d->lineCount = newTotalLines;
3195 emit lineCountChanged();
3203 const Qt::Alignment oldAlignment =
opt.alignment();
3214 opt.setAlignment((Qt::Alignment)(
int)(horizontalAlignment |
vAlign));
3216 opt.setAlignment(Qt::Alignment(
vAlign));
3220 opt.setTextDirection(
qGuiApp->inputMethod()->inputDirection());
3230 bool oldUseDesignMetrics =
opt.useDesignMetrics();
3233 if (oldWrapMode !=
opt.wrapMode() || oldAlignment !=
opt.alignment()
3234 || oldTextDirection !=
opt.textDirection()
3235 || oldUseDesignMetrics !=
opt.useDesignMetrics()) {
3271 d->handleFocusEvent(
event);
3278 d->handleFocusEvent(
event);
3286 if (!
q->isReadOnly())
3287 q->setCursorVisible(
focus);
3290 q->q_updateAlignment();
3293 qGuiApp->inputMethod()->show();
3295 q,
SLOT(q_updateAlignment()));
3300 q,
SLOT(q_updateAlignment()));
3308 emit q->editingFinished();
3330void QQuickTextEdit::q_canPasteChanged()
3333 bool old =
d->canPaste;
3334 d->canPaste =
d->control->canPaste();
3335 bool changed = old!=
d->canPaste || !
d->canPasteValid;
3336 d->canPasteValid =
true;
3338 emit canPasteChanged();
3357#if QT_CONFIG(texthtmlparser)
3358 return d->richText ||
d->markdownText
3360 :
cursor.selection().toPlainText();
3362 return cursor.selection().toPlainText();
3386#if QT_CONFIG(texthtmlparser)
3387 return cursor.selection().toHtml();
3389 return cursor.selection().toPlainText();
3391 }
else if (
d->markdownText) {
3392#if QT_CONFIG(textmarkdownwriter)
3393 return cursor.selection().toMarkdown();
3395 return cursor.selection().toPlainText();
3398 return cursor.selection().toPlainText();
3410 if (position < 0 || position >=
d->document->characterCount())
3416#if QT_CONFIG(texthtmlparser)
3421 }
else if (
d->markdownText) {
3422#if QT_CONFIG(textmarkdownreader)
3430 d->control->updateCursorRectangle(
false);
3447 cursor.removeSelectedText();
3448 d->control->updateCursorRectangle(
false);
3466 if (!
d->quickDocument) {
3468 connect(
d->quickDocument, &QQuickTextDocument::statusChanged,
d->quickDocument,
3469 [
d]() { d->onDocumentStatusChanged(); } );
3471 return d->quickDocument;
3480#if QT_CONFIG(cursor)
3481void QQuickTextEditPrivate::updateMouseCursorShape()
3521 return d->control->hoveredLink();
3523#if QT_CONFIG(cursor)
3526 return d->control->anchorAt(
pos);
3536 if (
d->isLinkHoveredConnected())
3544 if (
d->isLinkHoveredConnected())
3552 if (
d->isLinkHoveredConnected())
3573 if (!
d->document->isEmpty())
3577#if QT_CONFIG(texthtmlparser)
3582 }
else if (
d->format == MarkdownText) {
3583#if QT_CONFIG(textmarkdownreader)
3593 d->control->updateCursorRectangle(
false);
3608 return d->control->anchorAt(
QPointF(
x + topPadding(),
y + leftPadding()));
3625 return d->padding();
3634 d->extra.value().padding =
padding;
3636 if (isComponentComplete()) {
3640 emit paddingChanged();
3641 if (!
d->extra.isAllocated() || !
d->extra->explicitTopPadding)
3642 emit topPaddingChanged();
3643 if (!
d->extra.isAllocated() || !
d->extra->explicitLeftPadding)
3644 emit leftPaddingChanged();
3645 if (!
d->extra.isAllocated() || !
d->extra->explicitRightPadding)
3646 emit rightPaddingChanged();
3647 if (!
d->extra.isAllocated() || !
d->extra->explicitBottomPadding)
3648 emit bottomPaddingChanged();
3659 if (
d->extra.isAllocated() &&
d->extra->explicitTopPadding)
3660 return d->extra->topPadding;
3661 return d->padding();
3673 d->setTopPadding(0,
true);
3679 if (
d->extra.isAllocated() &&
d->extra->explicitLeftPadding)
3680 return d->extra->leftPadding;
3681 return d->padding();
3693 d->setLeftPadding(0,
true);
3699 if (
d->extra.isAllocated() &&
d->extra->explicitRightPadding)
3700 return d->extra->rightPadding;
3701 return d->padding();
3713 d->setRightPadding(0,
true);
3719 if (
d->extra.isAllocated() &&
d->extra->explicitBottomPadding)
3720 return d->extra->bottomPadding;
3721 return d->padding();
3733 d->setBottomPadding(0,
true);
3747 return d->document->defaultTextOption().tabStopDistance();
3753 QTextOption textOptions =
d->document->defaultTextOption();
3754 if (textOptions.tabStopDistance() ==
distance)
3758 d->document->setDefaultTextOption(textOptions);
3773void QQuickTextEdit::clear()
3776 d->resetInputMethod();
3777 d->control->clear();
3780#ifndef QT_NO_DEBUG_STREAM
3785 debug <<
"Node(startPos:" <<
n.m_startPos <<
"dirty:" <<
n.m_dirty <<
n.m_node <<
')';
3790#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
3791void QQuickTextEdit::setOldSelectionDefault()
3794 d->selectByMouse =
false;
3795 setKeepMouseGrab(
false);
3797 d->control->setTouchDragSelectionEnabled(
true);
3798 qCDebug(lcTextEdit,
"pre-6.4 behavior chosen: selectByMouse defaults false; if enabled, touchscreen acts like a mouse");
3805 setOldSelectionDefault();
3811#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.
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 qCWarning(category,...)
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
QT_BEGIN_NAMESPACE 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)