7#include <private/qqmldebugserviceinterfaces_p.h>
8#include <private/qqmldebugconnector_p.h>
10#include <QtQuick/private/qsgcontext_p.h>
11#include <private/qqmlglobal_p.h>
12#include <private/qsgadaptationlayer_p.h>
16#include <QtQuick/private/qsgtexture_p.h>
18#include <QtQml/qqmlinfo.h>
19#include <QtGui/qevent.h>
20#include <QtGui/qabstracttextdocumentlayout.h>
21#include <QtGui/qpainter.h>
22#include <QtGui/qtextdocument.h>
23#include <QtGui/qtextobject.h>
24#include <QtGui/qtextcursor.h>
25#include <QtGui/qguiapplication.h>
26#include <QtGui/qinputmethod.h>
28#include <private/qtextengine_p.h>
29#include <private/qquickstyledtext_p.h>
30#include <QtQuick/private/qquickpixmap_p.h>
40using namespace
Qt::StringLiterals;
44#if !defined(QQUICKTEXT_LARGETEXT_THRESHOLD)
45 #define QQUICKTEXT_LARGETEXT_THRESHOLD 10000
51 : fontInfo(
font), lineWidth(0)
52 ,
color(0xFF000000), linkColor(0xFF0000FF), styleColor(0xFF000000)
53 , lineCount(1), multilengthEos(-1)
58 , updateType(UpdatePaintNode)
59 , maximumLineCountValid(
false), updateOnComponentComplete(true), richText(
false)
61 , requireImplicitSize(
false), implicitWidthValid(
false), implicitHeightValid(
false)
62 , truncated(
false), hAlignImplicit(true), rightToLeftText(
false)
63 , layoutTextElided(
false), textHasChanged(true), needToUpdateLayout(
false), formatModifiesFontSize(
false)
65 , updateSizeRecursionGuard(
false)
76 , explicitTopPadding(
false)
77 , explicitLeftPadding(
false)
78 , explicitRightPadding(
false)
79 , explicitBottomPadding(
false)
82 , minimumPixelSize(12)
83 , minimumPointSize(12)
84 , maximumLineCount(INT_MAX)
85 , renderTypeQuality(
QQuickText::DefaultRenderTypeQuality)
86 , lineHeightValid(
false)
87 , lineHeightMode(
QQuickText::ProportionalHeight)
102 if (
extra.isAllocated()) {
104 extra->imgTags.clear();
133 return q->width() -
q->leftPadding() -
q->rightPadding();
139 return q->height() -
q->topPadding() -
q->bottomPadding();
145 qreal oldPadding =
q->topPadding();
152 emit q->topPaddingChanged();
159 qreal oldPadding =
q->leftPadding();
166 emit q->leftPaddingChanged();
173 qreal oldPadding =
q->rightPadding();
180 emit q->rightPaddingChanged();
187 qreal oldPadding =
q->bottomPadding();
194 emit q->bottomPaddingChanged();
207void QQuickText::q_updateLayout()
216 if (!
q->isComponentComplete()) {
223 if (
extra.isAllocated())
224 extra->visibleImgTags.clear();
233 bool fontSizeModified =
false;
234 QList<QQuickStyledTextImgTag*> someImgTags =
extra.isAllocated() ?
extra->imgTags : QList<QQuickStyledTextImgTag*>();
236 if (someImgTags.size() ||
extra.isAllocated())
237 extra.value().imgTags = someImgTags;
250 }
else if (
extra.isAllocated() &&
extra->lineHeightValid) {
258 cursor.mergeBlockFormat(blockFormat);
291 for (
auto it =
d->extra->pixmapsInProgress.
cbegin();
it !=
d->extra->pixmapsInProgress.
cend();) {
293 if (job->url() ==
url) {
294 if (job->isError()) {
300 qCDebug(lcText) <<
"already downloading" <<
url;
302 return job->isReady() ? job->image() :
QVariant();
312 p->connectFinished(
this,
SLOT(resourceRequestFinished()));
313 d->extra->pixmapsInProgress.append(
p);
315 return p->isReady() ?
p->image() :
QVariant();
321void QQuickText::resourceRequestFinished()
325 for (
auto it =
d->extra->pixmapsInProgress.
cbegin();
it !=
d->extra->pixmapsInProgress.
cend();) {
327 if (job->isError()) {
329 qCDebug(lcText) <<
"failed to load" << job->url();
331 }
else if (job->isReady()) {
335 qCDebug(lcText) << (
res.isValid() ?
"done downloading" :
"failed to load") << job->url();
344 Q_ASSERT(
d->extra->pixmapsInProgress.isEmpty());
352void QQuickText::imageDownloadFinished()
355 if (!
d->extra.isAllocated())
358 if (std::any_of(
d->extra->imgTags.cbegin(),
d->extra->imgTags.cend(),
359 [] (
auto *
image) { return image->pix && image->pix->isLoading(); })) {
370 if (!
img->size.isValid()) {
371 img->size =
img->pix->implicitSize();
377 d->textHasChanged =
true;
391 if (
q->heightValid()) {
398 q->setBaselineOffset(
baseline + yoff +
q->topPadding());
404 const QSizeF contentSize(
q->contentWidth(),
q->contentHeight());
406 if (contentSize != previousSize) {
407 emit q->contentSizeChanged();
408 if (contentSize.
width() != previousSize.
width())
409 emit q->contentWidthChanged(contentSize.
width());
411 emit q->contentHeightChanged(contentSize.
height());
419 if (!
q->isComponentComplete()) {
432 qreal hPadding =
q->leftPadding() +
q->rightPadding();
433 qreal vPadding =
q->topPadding() +
q->bottomPadding();
435 const QSizeF previousSize(
q->contentWidth(),
q->contentHeight());
455 emit q->lineCountChanged();
491 qreal naturalWidth = 0;
493 extra->doc->setTextWidth(-1);
494 naturalWidth =
extra->doc->idealWidth();
497 q->setImplicitWidth(naturalWidth + hPadding);
507 extra->doc->setTextWidth(
extra->doc->idealWidth());
523 qreal oldWidth =
q->width();
525 if (!
q->widthValid())
526 iWidth =
size.width();
546 firstBlock = firstBlock.
next();
556 (lastLine.y() + lastBlock.
layout()->
position().
y() + lastLine.ascent()) - (firstLine.y() + firstBlock.
layout()->
position().
y() + firstLine.ascent()));
585 m_fullLayoutTextLength =
length;
616 return m_line->
width();
701 const int start,
const int length,
int offset, QVector<QTextLayout::FormatRange> *elidedFormats)
708 if (formatLength > 0) {
710 format.length = formatLength;
711 elidedFormats->append(
format);
724 line.textLength() + nextLine->textLength());
729 elideText[elideText.size() - 1] =
elideChar;
772 emit q->truncatedChanged();
777 emit q->lineCountChanged();
792 if (
extra.isAllocated())
793 extra->visibleImgTags.clear();
796 if (textOption.
alignment() !=
q->effectiveHAlign()
799 textOption.
setAlignment(Qt::Alignment(
q->effectiveHAlign()));
824 const qreal minimumSize = pixelSize
829 ? qMin<qreal>(minimumSize, largeFont)
831 qreal scaledFontSize = largeFont;
832 const qreal sizeFittingThreshold(0.01);
842 int visibleCount = 0;
859 scaledFont.setPixelSize(scaledFontSize);
861 scaledFont.setPointSizeF(scaledFontSize);
868 bool wrapped =
false;
869 bool truncateHeight =
false;
872 int unwrappedLineCount = 1;
875 qreal naturalHeight = 0;
876 qreal previousHeight = 0;
881 for (visibleCount = 1; ; ++visibleCount) {
884 if (noBreakLastLine && visibleCount == maxLineCount)
891 if (noBreakLastLine && visibleCount == maxLineCount)
894 unelidedRect = br.
united(
line.naturalTextRect());
898 if (multilineElide && naturalHeight > maxHeight && visibleCount > 1) {
905 truncateHeight =
true;
910 elideText = layoutText.at(
line.textStart() - 1) != QChar::LineSeparator
913 elideStart = previousLine.textStart();
920 const bool isLastLine =
line.textStart() +
line.textLength() >= layoutText.
size();
922 if (singlelineElide && visibleCount == 1 &&
line.naturalTextWidth() >
line.width()) {
936 elideStart =
line.textStart();
937 elideEnd = elideStart +
line.textLength();
944 const bool wrappedLine = layoutText.at(
line.textStart() +
line.textLength() - 1) != QChar::LineSeparator;
945 wrapped |= wrappedLine;
948 ++unwrappedLineCount;
951 if (visibleCount == maxLineCount) {
955 if (multilineElide) {
961 elideText = wrappedLine
964 elideStart =
line.textStart();
992 if (layoutText.at(
line.textStart() - 1) == QChar::LineSeparator)
993 ++unwrappedLineCount;
999 const int eol =
line.isValid()
1000 ?
line.textStart() +
line.textLength()
1001 : layoutText.
size();
1002 if (eol < layoutText.
size() && layoutText.at(eol) != QChar::LineSeparator)
1004 for (;
line.isValid() && unwrappedLineCount <= maxLineCount; ++unwrappedLineCount)
1013 q->setImplicitSize(naturalWidth +
q->leftPadding() +
q->rightPadding(), naturalHeight +
qMax(
lineHeightOffset(), 0) +
q->topPadding() +
q->bottomPadding());
1028 const qreal oldHeight = maxHeight;
1033 lineWidth =
q->widthValid() &&
q->width() > 0 ? availWidth : naturalWidth;
1034 maxHeight =
q->heightValid() ? availHeight : FLT_MAX;
1039 && (singlelineElide || multilineElide || canWrap || horizontalFit
1049 if ((maxHeight <
qMin(oldHeight, naturalHeight) || (
heightExceeded && maxHeight > oldHeight))
1065 if (
line.isValid()) {
1068 if (!
line.isValid())
1086 const qreal oldHeight = maxHeight;
1090 if ((maxHeight <
qMin(oldHeight, naturalHeight) || (
heightExceeded && maxHeight > oldHeight))
1102 if (eos != -1 && elide) {
1103 int start = eos + 1;
1119 lastLine.y() - firstLine.y());
1124 if (!horizontalFit && !verticalFit)
1132 if (horizontalFit) {
1133 if (unelidedRect.width() >
lineWidth || (!verticalFit && wrapped)) {
1135 largeFont = scaledFontSize;
1137 scaledFontSize = (smallFont + largeFont) / 2;
1140 }
else if (!verticalFit) {
1141 smallFont = scaledFontSize;
1144 if ((largeFont - smallFont) < sizeFittingThreshold)
1147 scaledFontSize = (smallFont + largeFont) / 2;
1152 if (truncateHeight || unelidedRect.height() > maxHeight) {
1154 largeFont = scaledFontSize;
1156 scaledFontSize = (smallFont + largeFont) / 2;
1159 smallFont = scaledFontSize;
1162 if ((largeFont - smallFont) < sizeFittingThreshold)
1165 scaledFontSize = (smallFont + largeFont) / 2;
1181 emit q->fontInfoChanged();
1196 QVector<QTextLayout::FormatRange>
formats;
1209 elideEnd - elideText.size() +
index + 1,
1210 elideText.size() -
index - 1,
1236 br = br.
united(elidedLine.naturalTextRect());
1238 if (visibleCount == 1)
1247 if (firstLine.isValid())
1248 *
baseline = firstLine.y() + firstLine.ascent();
1256 emit q->lineCountChanged();
1260 emit q->truncatedChanged();
1270 if (
extra.isAllocated() &&
extra->imgTags.isEmpty()) {
1278 qreal totalLineHeight = textHeight;
1280 QList<QQuickStyledTextImgTag *> imagesInLine;
1282 if (
extra.isAllocated()) {
1284 if (
image->position >=
line.textStart() &&
1292 if (
image->pix->isLoading()) {
1293 image->pix->connectFinished(
q,
SLOT(imageDownloadFinished()));
1294 }
else if (
image->pix->isReady()) {
1295 if (!
image->size.isValid()) {
1301 }
else if (
image->pix->isError()) {
1310 image->pos.setY((textHeight / 2.0) - (ih / 2.0));
1312 image->pos.setY(textHeight - ih);
1313 imagesInLine <<
image;
1320 totalLineHeight =
qMax(totalLineHeight, textTop +
image->pos.y() +
image->size.height());
1321 const int leadX =
line.cursorToX(
image->position);
1323 const bool rtl = trailX < leadX;
1352 auto *doc =
extra->doc;
1355 doc->setPageSize(
QSizeF(0, 0));
1356 doc->setDocumentMargin(0);
1358 doc->setBaseUrl(
context ?
context->resolvedUrl(
q->baseUrl()) :
q->baseUrl());
1365#if QT_CONFIG(textmarkdownreader)
1370#if QT_CONFIG(texthtmlparser)
1380 return (
window ?
window->effectiveDevicePixelRatio() :
qApp->devicePixelRatio());
1466 if (
d->extra.isAllocated()) {
1468 d->extra->pixmapsInProgress.clear();
1875 return d->sourceFont;
1881 if (
d->sourceFont ==
font)
1884 d->sourceFont =
font;
1891 if (
d->font.pointSizeF() != -1) {
1894 d->font.setPointSizeF(
size/2.0);
1897 if (oldFont !=
d->font) {
1900 if (
d->formatModifiesFontSize)
1901 d->textHasChanged =
true;
1902 d->implicitWidthValid =
false;
1903 d->implicitHeightValid =
false;
1920 d->implicitWidthValid =
false;
1921 d->implicitHeightValid =
false;
1927 bool needUpdateLayout =
false;
1933 d->implicitWidthValid =
false;
1934 d->implicitHeightValid =
false;
1935 needUpdateLayout =
true;
1938 if (
d->extra.isAllocated()) {
1943 needUpdateLayout =
true;
1948 if (needUpdateLayout)
1983 d->richText =
d->format ==
RichText ||
d->markdownText;
1988 d->updateDocumentText();
1991 d->rightToLeftText =
d->text.isRightToLeft();
1993 d->determineHorizontalAlignment();
1995 d->textHasChanged =
true;
1996 d->implicitWidthValid =
false;
1997 d->implicitHeightValid =
false;
1999 if (
d->extra.isAllocated()) {
2001 d->extra->imgTags.clear();
2040 if (
d->color ==
rgb)
2071 if (
d->linkColor ==
rgb)
2150 if (
d->styleColor ==
rgb)
2153 d->styleColor =
rgb;
2194 bool forceAlign =
d->hAlignImplicit &&
d->effectiveLayoutMirror;
2195 d->hAlignImplicit =
false;
2203 d->hAlignImplicit =
true;
2212 if (!
d->hAlignImplicit &&
d->effectiveLayoutMirror) {
2213 switch (
d->hAlign) {
2224 return effectiveAlignment;
2235 if (oldEffectiveHAlign !=
q->effectiveHAlign())
2236 emit q->effectiveHorizontalAlignmentChanged();
2258 if (
q->isComponentComplete()) {
2261 emit q->effectiveHorizontalAlignmentChanged();
2275 if (
d->vAlign == align)
2313 if (
mode ==
d->wrapMode)
2334 return d->lineCount;
2350 return d->truncated;
2367 return d->maximumLineCount();
2374 d->maximumLineCountValid = lines==INT_MAX ?
false :
true;
2375 if (
d->maximumLineCount() != lines) {
2376 d->extra.value().maximumLineCount = lines;
2377 d->implicitHeightValid =
false;
2387 if (
d->truncated !=
false) {
2388 d->truncated =
false;
2467 bool wasRich =
d->richText;
2473 if (!wasRich &&
d->richText) {
2474 d->updateDocumentText();
2477 d->rightToLeftText =
d->text.isRightToLeft();
2478 d->textHasChanged =
true;
2480 d->determineHorizontalAlignment();
2518 return d->elideMode;
2524 if (
mode ==
d->elideMode)
2527 d->elideMode =
mode;
2559 if (!
d->extra.isAllocated() ||
d->extra->baseUrl.isEmpty()) {
2565 return d->extra->baseUrl;
2573 d->extra.value().baseUrl =
url;
2577 d->extra->doc->setBaseUrl(
url);
2579 if (
d->styledText) {
2580 d->textHasChanged =
true;
2581 if (
d->extra.isAllocated()) {
2583 d->extra->imgTags.clear();
2615 rect.adjust(-1, 0, 1, 2);
2638 rect.adjust(-1, 0, 1, 2);
2646 if (
d->text.isEmpty()) {
2658 bool widthMaximum = newGeometry.
width() >= oldGeometry.
width() && !
d->widthExceeded;
2659 bool heightMaximum = newGeometry.
height() >= oldGeometry.
height() && !
d->heightExceeded;
2664 goto geomChangeDone;
2673 if (!wrapped && !
elide && !scaleFont && !verticalPositionChanged)
2674 goto geomChangeDone;
2679 goto geomChangeDone;
2682 if (widthMaximum && heightMaximum && !
d->isLineLaidOutConnected() && !verticalPositionChanged)
2683 goto geomChangeDone;
2685 if (!(
widthChanged || widthMaximum) && !
d->isLineLaidOutConnected()) {
2686 if (!verticalPositionChanged) {
2690 goto geomChangeDone;
2692 if (
d->lineCount ==
d->maximumLineCount())
2693 goto geomChangeDone;
2694 }
else if (newGeometry.
height() < oldGeometry.
height()) {
2695 if (
d->lineCount < 2 && !verticalScale && newGeometry.
height() > 0)
2696 goto geomChangeDone;
2700 && !(
d->maximumLineCountValid &&
d->widthExceeded)) {
2701 goto geomChangeDone;
2706 if (oldGeometry.
width() > 0) {
2710 goto geomChangeDone;
2714 if (
d->updateOnComponentComplete ||
d->textHasChanged) {
2726void QQuickText::triggerPreprocess()
2739 if (
d->text.isEmpty()) {
2756 node =
d->sceneGraphContext()->createInternalTextNode(
d->sceneGraphRenderContext());
2777 }
else if (
d->layedOutTextRect.width() > 0) {
2783 int unelidedLineCount =
d->lineCount;
2785 unelidedLineCount -= 1;
2786 if (unelidedLineCount > 0)
2792 if (
d->extra.isAllocated()) {
2794 if (
img->pix &&
img->pix->isReady())
2810 const bool clipNodeChanged =
2811 d->componentComplete &&
d->clipNode() &&
d->clipNode()->rect() !=
clipRect();
2812 if (clipNodeChanged)
2819 d->polishSize =
true;
2821 if (
d->polishSize) {
2823 d->polishSize =
false;
2837 return d->layedOutTextRect.width();
2849 return d->layedOutTextRect.height() +
qMax(
d->lineHeightOffset(), 0);
2864 return d->lineHeight();
2874 d->extra.value().lineHeightValid =
true;
2876 d->implicitHeightValid =
false;
2894 return d->lineHeightMode();
2900 if (
mode ==
d->lineHeightMode())
2903 d->implicitHeightValid =
false;
2904 d->extra.value().lineHeightValid =
true;
2905 d->extra.value().lineHeightMode =
mode;
2949 return d->fontSizeMode();
2955 if (
d->fontSizeMode() ==
mode)
2958 d->polishSize =
true;
2961 d->extra.value().fontSizeMode =
mode;
2978 return d->minimumPixelSize();
2984 if (
d->minimumPixelSize() ==
size)
2988 d->polishSize =
true;
2991 d->extra.value().minimumPixelSize =
size;
3008 return d->minimumPointSize();
3014 if (
d->minimumPointSize() ==
size)
3018 d->polishSize =
true;
3021 d->extra.value().minimumPointSize =
size;
3031 if (
d->richText &&
d->extra.isAllocated())
3032 return d->extra->pixmapsInProgress.size();
3040 if (
d->updateOnComponentComplete) {
3042 d->updateDocumentText();
3044 d->rightToLeftText =
d->text.isRightToLeft();
3046 d->determineHorizontalAlignment();
3049 if (
d->updateOnComponentComplete)
3061 if (formatRange.format.isAnchor()
3062 && charPos >= formatRange.start
3063 && charPos < formatRange.start + formatRange.length) {
3064 return formatRange.format.anchorHref();
3076 QPointF translatedMousePos = mousePos;
3077 translatedMousePos.
rx() -=
q->leftPadding();
3086 return extra->doc->documentLayout()->anchorAt(translatedMousePos);
3103 if (
d->isLinkActivatedConnected())
3104 link =
d->anchorAt(
event->position());
3107 event->setAccepted(
false);
3109 d->extra.value().activeLink = link;
3114 if (!
event->isAccepted())
3127 if (
d->isLinkActivatedConnected())
3128 link =
d->anchorAt(
event->position());
3130 if (!link.
isEmpty() &&
d->extra.isAllocated() &&
d->extra->activeLink == link)
3133 event->setAccepted(
false);
3135 if (!
event->isAccepted())
3148 if (formatRange.format.isAnchor()) {
3149 const int start = formatRange.start;
3150 const int len = formatRange.length;
3155 r.setHeight(
line.height());
3161 const QString anchorHref = formatRange.format.anchorHref();
3162 if (anchorName.isEmpty())
3163 anchorName = anchorHref;
3164 links->append( { anchorName, anchorHref,
start,
start +
len,
r.toRect()} );
3171 QVector<QQuickTextPrivate::LinkDesc>
links;
3203 if (
d->extra.isAllocated())
3204 return d->extra->hoveredLink;
3206#if QT_CONFIG(cursor)
3209 return d->anchorAt(
pos);
3226 extra.value().hoveredLink = link;
3236 d->processHoverEvent(
event);
3242 d->processHoverEvent(
event);
3248 d->processHoverEvent(
event);
3254 d->textHasChanged =
true;
3294 return d->renderTypeQuality();
3309 emit renderTypeQualityChanged();
3340 return d->renderType;
3356#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
3357#if QT_DEPRECATED_SINCE(5, 15)
3364void QQuickText::doLayout()
3377void QQuickText::forceLayout()
3408 if (
d->richText &&
d->extra.isAllocated() &&
d->extra->doc !=
nullptr) {
3410 for (block =
d->extra->doc->firstBlock(); block.
isValid(); block = block.
next()) {
3415 if (
d->layout.engine() !=
nullptr)
3416 d->layout.engine()->resetFontEngineCache();
3434 return d->padding();
3443 d->extra.value().padding =
padding;
3445 emit paddingChanged();
3446 if (!
d->extra.isAllocated() || !
d->extra->explicitTopPadding)
3447 emit topPaddingChanged();
3448 if (!
d->extra.isAllocated() || !
d->extra->explicitLeftPadding)
3449 emit leftPaddingChanged();
3450 if (!
d->extra.isAllocated() || !
d->extra->explicitRightPadding)
3451 emit rightPaddingChanged();
3452 if (!
d->extra.isAllocated() || !
d->extra->explicitBottomPadding)
3453 emit bottomPaddingChanged();
3464 if (
d->extra.isAllocated() &&
d->extra->explicitTopPadding)
3465 return d->extra->topPadding;
3466 return d->padding();
3478 d->setTopPadding(0,
true);
3484 if (
d->extra.isAllocated() &&
d->extra->explicitLeftPadding)
3485 return d->extra->leftPadding;
3486 return d->padding();
3498 d->setLeftPadding(0,
true);
3504 if (
d->extra.isAllocated() &&
d->extra->explicitRightPadding)
3505 return d->extra->rightPadding;
3506 return d->padding();
3518 d->setRightPadding(0,
true);
3524 if (
d->extra.isAllocated() &&
d->extra->explicitBottomPadding)
3525 return d->extra->bottomPadding;
3526 return d->padding();
3538 d->setBottomPadding(0,
true);
3602 qmlWarning(
this) <<
"fontInfo: item has no JS engine";
3637#include "moc_qquicktext_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
static QColor fromRgba(QRgb rgba) noexcept
Static convenience function that returns a QColor constructed from the given QRgb value rgba.
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
qreal pointSizeF() const
Returns the point size of the matched window system font.
int pixelSize() const
Returns the pixel size of the matched window system font.
QString family() const
Returns the family name of the matched window system font.
bool italic() const
Returns the italic value of the matched window system font.
QString styleName() const
int weight() const
Returns the weight of the matched window system font.
\reentrant \inmodule QtGui
qreal ascent() const
Returns the ascent of the font.
int pixelSize() const
Returns the pixel size of the font if it was set with setPixelSize().
qreal pointSizeF() const
Returns the point size of the font.
static QInputMethod * inputMethod()
returns the input method.
The QJSEngine class provides an environment for evaluating JavaScript code.
QJSValue newObject()
Creates a JavaScript object of class Object.
The QJSValue class acts as a container for Qt/JavaScript data types.
void setProperty(const QString &name, const QJSValue &value)
Sets the value of this QJSValue's property with the given name to the given value.
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
\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.
constexpr qreal & rx() noexcept
Returns a reference to the x coordinate of this point.
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 bool transformChanged(QQuickItem *transformedItem)
virtual void implicitHeightChanged()
quint32 implicitAntialiasing
virtual void implicitWidthChanged()
QQuickAnchorLine baseline() const
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
QPointF mapToScene(const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within the scene's coor...
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.
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)
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
void setAcceptHoverEvents(bool enabled)
If enabled is true, this sets the item to accept hover events; otherwise, hover events are not accept...
void setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons accepted by this item to buttons.
QQuickWindow * window() const
Returns the window in which this item is rendered.
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.
bool antialiasing
\qmlproperty bool QtQuick::Item::antialiasing
bool smooth
\qmlproperty bool QtQuick::Item::smooth
bool widthValid() const
Returns whether the width property has been set explicitly.
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.
@ ItemAntialiasingHasChanged
@ ItemDevicePixelRatioHasChanged
void update()
Schedules a call to updatePaintNode() for this item.
void polish()
Schedules a polish event for this item.
static bool isScalableImageFormat(const QUrl &url)
static void parse(const QString &string, QTextLayout &layout, QList< QQuickStyledTextImgTag * > &imgTags, const QUrl &baseUrl, QQmlContext *context, bool preloadImages, bool *fontSizeModified)
void setWidth(qreal width)
void setFullLayoutTextLength(int length)
void setLine(QTextLine *line)
void setLineOffset(int offset)
void setHeight(qreal height)
QQuickText::LineHeightMode lineHeightMode() const
qreal getImplicitHeight() const override
QVector< LinkDesc > getLinks() const
int minimumPixelSize() const
QLazilyAllocated< ExtraData > extra
bool updateOnComponentComplete
qreal availableHeight() const
void setRightPadding(qreal value, bool reset=false)
void elideFormats(int start, int length, int offset, QVector< QTextLayout::FormatRange > *elidedFormats)
bool isLinkActivatedConnected()
bool transformChanged(QQuickItem *transformedItem) override
int minimumPointSize() const
void processHoverEvent(QHoverEvent *event)
QScopedPointer< QTextLayout > elideLayout
int maximumLineCount() const
void ensureDoc()
Ensures the QQuickTextPrivate::doc variable is set to a valid text document.
QScopedPointer< QQuickTextLine > textLine
QQuickText::RenderType renderType
bool updateSizeRecursionGuard
qreal getImplicitWidth() const override
QQuickText::TextElideMode elideMode
QQuickText::WrapMode wrapMode
bool maximumLineCountValid
void setBottomPadding(qreal value, bool reset=false)
bool setHAlign(QQuickText::HAlignment, bool forceAlign=false)
qreal availableWidth() const
int lineHeightOffset() const
Returns the y offset when aligning text with a non-1.0 lineHeight.
void updateDocumentText()
void setTopPadding(qreal value, bool reset=false)
void mirrorChange() override
bool determineHorizontalAlignment()
QQuickText::VAlignment vAlign
bool formatModifiesFontSize
static const int largeTextSizeThreshold
bool isLineLaidOutConnected()
QString elidedText(qreal lineWidth, const QTextLine &line, const QTextLine *nextLine=nullptr) const
qreal devicePixelRatio() const
void setLeftPadding(qreal value, bool reset=false)
bool isLinkHoveredConnected()
QQuickText::FontSizeMode fontSizeMode() const
void updateBaseline(qreal baseline, qreal dy)
static const QChar elideChar
void signalSizeChange(const QSizeF &previousSize)
void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height)
void setupCustomLineGeometry(QTextLine &line, qreal &height, int fullLayoutTextLength, int lineOffset=0)
QStringList links() const
QQuickText::HAlignment hAlign
static QString anchorAt(const QTextLayout *layout, const QPointF &mousePos)
QRectF setupTextLayout(qreal *const baseline)
Lays out the QQuickTextPrivate::layout QTextLayout in the constraints of the QQuickText.
static qreal alignedX(qreal textWidth, qreal itemWidth, int alignment)
static qreal alignedY(qreal textHeight, qreal itemHeight, int alignment)
QQuickText(QQuickItem *parent=nullptr)
\qmltype Text \instantiates QQuickText \inqmlmodule QtQuick\inherits Item
void verticalAlignmentChanged(QQuickText::VAlignment alignment)
void minimumPointSizeChanged()
void setBaseUrl(const QUrl &url)
void setRenderType(RenderType renderType)
void invalidate() override
void updatePolish() override
This function should perform any layout as required for this item.
QRectF boundingRect() const override
Returns the extents of the text after layout.
void setPadding(qreal padding)
int resourcesLoading() const
Returns the number of resources (images) that are being loaded asynchronously.
void minimumPixelSizeChanged()
void setText(const QString &)
void setStyle(TextStyle style)
void setFont(const QFont &font)
HAlignment effectiveHAlign() const
void textChanged(const QString &text)
void elideModeChanged(QQuickText::TextElideMode mode)
void setLeftPadding(qreal padding)
QRectF clipRect() const override
Returns a rectangular area slightly larger than what is currently visible in \l viewportItem(); other...
void setMinimumPixelSize(int size)
FontSizeMode fontSizeMode
void setMaximumLineCount(int lines)
void lineHeightModeChanged(LineHeightMode mode)
void mouseReleaseEvent(QMouseEvent *event) override
HAlignment hAlign() const
\qmlproperty enumeration QtQuick::Text::horizontalAlignment \qmlproperty enumeration QtQuick::Text::v...
void fontSizeModeChanged()
void fontChanged(const QFont &font)
void setElideMode(TextElideMode)
VAlignment vAlign() const
void setLineHeightMode(LineHeightMode)
void setLinkColor(const QColor &color)
void componentComplete() override
void setLineHeight(qreal lineHeight)
void setVAlign(VAlignment align)
void hoverLeaveEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
void setHAlign(HAlignment align)
void mousePressEvent(QMouseEvent *event) override
void setFontSizeMode(FontSizeMode mode)
void styleChanged(QQuickText::TextStyle style)
void setTopPadding(qreal padding)
void textFormatChanged(QQuickText::TextFormat textFormat)
void setTextFormat(TextFormat format)
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
TextElideMode elideMode() const
\qmlproperty enumeration QtQuick::Text::elide
void linkActivated(const QString &link)
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
void maximumLineCountChanged()
void setColor(const QColor &c)
void lineHeightChanged(qreal lineHeight)
void hoverMoveEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-move events for an item.
void setRightPadding(qreal padding)
LineHeightMode lineHeightMode
void setWrapMode(WrapMode w)
void invalidateFontCaches()
void setBottomPadding(qreal padding)
void setMinimumPointSize(int size)
void setRenderTypeQuality(int renderTypeQuality)
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
void setStyleColor(const QColor &c)
void resetMaximumLineCount()
void hoverEnterEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
void resetBottomPadding()
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr void setTop(qreal pos) noexcept
Sets the top edge of the rectangle to the given finite y coordinate.
constexpr void setHeight(qreal h) noexcept
Sets the height of the rectangle to the given finite height.
constexpr void moveTop(qreal pos) noexcept
Moves the rectangle vertically, leaving the rectangle's top line at the given finite y coordinate.
QRectF united(const QRectF &other) const noexcept
\inmodule QtCore\reentrant
constexpr QSize size() const noexcept
Returns the size of the rectangle.
void addImage(const QRectF &rect, const QImage &image)
void setTextStyle(TextStyle textStyle) override
Sets the style of the rendered text to textStyle.
void clear() override
Clears the contents of the node, deleting nodes and other data that represents the layouts and docume...
void setLinkColor(QColor linkColor) override
Sets the color of or hyperlinks to linkColor in the text.
void setFiltering(QSGTexture::Filtering filtering) override
Sets the sampling mode used when scaling images that are part of the displayed text to filtering.
void setRenderType(RenderType renderType) override
Sets the type of glyph node in use to renderType.
void setRenderTypeQuality(int renderTypeQuality) override
If the \l renderType() in use supports it, set the quality to use when rendering the text.
void setStyleColor(QColor styleColor) override
Sets the style color to use when rendering the text to styleColor.
void setColor(QColor color) override
Sets the main color to use when rendering the text to color.
void setViewport(const QRectF &viewport) override
Sets the bounding rect of the viewport where the text is displayed to viewport.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
void addTextLayout(QPointF position, QTextLayout *layout, int selectionStart=-1, int selectionCount=-1, int lineStart=0, int lineCount=-1)
Adds the contents of layout to the text node at position.
void addTextDocument(QPointF position, QTextDocument *document, int selectionStart=-1, int selectionCount=-1)
Adds the contents of document to the text node at position.
RenderType
This enum type describes type of glyph node used for rendering the text.
TextStyle
This enum type describes styles that can be applied to text rendering.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
const_iterator cend() const noexcept
iterator erase(const_iterator i)
const_iterator cbegin() const noexcept
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & replace(qsizetype i, qsizetype len, QChar after)
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void setLineHeight(qreal height, int heightType)
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.
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
\reentrant \inmodule QtGui
\reentrant \inmodule QtGui
ResourceType
This enum describes the types of resources that can be loaded by QTextDocument's loadResource() funct...
void resetFontEngineCache()
QString elidedText(Qt::TextElideMode mode, QFixed width, int flags=0, int from=0, int count=-1) const
const QTextOption & textOption() const
Returns the current text option used to control the layout process.
void setFont(const QFont &f)
Sets the layout's font to the given font.
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
void beginLayout()
Begins the layout process.
QTextEngine * engine() const
void setCacheEnabled(bool enable)
Enables caching of the complete layout information if enable is true; otherwise disables layout cachi...
void setFormats(const QList< FormatRange > &overrides)
void setText(const QString &string)
Sets the layout's text to the given string.
QList< FormatRange > formats() const
QString text() const
Returns the layout's text.
int lineCount() const
Returns the number of lines in this text layout.
qreal maximumWidth() const
The maximum width the layout could expand to; this is essentially the width of the entire text.
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
void setTextOption(const QTextOption &option)
Sets the text option structure that controls the layout process to the given option.
QFont font() const
Returns the current font that is used for the layout, or a default font if none is set.
void endLayout()
Ends the layout process.
int textStart() const
Returns the start of the line from the beginning of the string passed to the QTextLayout.
qreal height() const
Returns the line's height.
qreal naturalTextWidth() const
Returns the width of the line that is occupied by text.
qreal y() const
Returns the line's y position.
qreal width() const
Returns the line's width as specified by the layout() function.
void setPosition(const QPointF &pos)
Moves the line to position pos.
void setLineWidth(qreal width)
Lays out the line with the given width.
qreal ascent() const
Returns the line's ascent.
int lineNumber() const
Returns the position of the line in the text engine.
qreal x() const
Returns the line's x position.
int textLength() const
Returns the length of the text in the line.
WrapMode wrapMode() const
Returns the text wrap mode defined by the option.
Qt::Alignment alignment() const
Returns the text alignment defined by the option.
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
void setUseDesignMetrics(bool b)
If enable is true then the layout will use design metrics; otherwise it will use the metrics of the p...
void setAlignment(Qt::Alignment alignment)
Sets the option's text alignment to the specified alignment.
bool useDesignMetrics() const
Returns true if the layout uses design rather than device metrics; otherwise returns false.
WrapMode
This enum describes how text is wrapped in a document.
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
Q_GUI_EXPORT bool mightBeRichText(QAnyStringView)
Returns true if the string text is likely to be rich text; otherwise returns false.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
Q_QML_EXPORT QJSEngine * qjsEngine(const QObject *)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
QQmlContext * qmlContext(const QObject *obj)
#define IS_SIGNAL_CONNECTED(Sender, SenderType, Name, Arguments)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
#define QQUICKTEXT_LARGETEXT_THRESHOLD
static void getLinks_helper(const QTextLayout *layout, QVector< QQuickTextPrivate::LinkDesc > *links)
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
#define QStringLiteral(str)
bool testFlag(MaskType mask, FlagType flag)
QUrl url("example.com")
[constructor-url-reference]
static constexpr QFixed fromReal(qreal r)
\inmodule QtCore \reentrant