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>
39using namespace
Qt::StringLiterals;
43#if !defined(QQUICKTEXT_LARGETEXT_THRESHOLD)
44 #define QQUICKTEXT_LARGETEXT_THRESHOLD 10000
50 : fontInfo(
font), lineWidth(0)
51 ,
color(0xFF000000), linkColor(0xFF0000FF), styleColor(0xFF000000)
52 , lineCount(1), multilengthEos(-1)
57 , updateType(UpdatePaintNode)
58 , maximumLineCountValid(
false), updateOnComponentComplete(true), richText(
false)
60 , requireImplicitSize(
false), implicitWidthValid(
false), implicitHeightValid(
false)
61 , truncated(
false), hAlignImplicit(true), rightToLeftText(
false)
62 , layoutTextElided(
false), textHasChanged(true), needToUpdateLayout(
false), formatModifiesFontSize(
false)
64 , updateSizeRecursionGuard(
false)
75 , explicitTopPadding(
false)
76 , explicitLeftPadding(
false)
77 , explicitRightPadding(
false)
78 , explicitBottomPadding(
false)
81 , minimumPixelSize(12)
82 , minimumPointSize(12)
83 , maximumLineCount(INT_MAX)
84 , renderTypeQuality(
QQuickText::DefaultRenderTypeQuality)
85 , lineHeightValid(
false)
86 , lineHeightMode(
QQuickText::ProportionalHeight)
132 return q->width() -
q->leftPadding() -
q->rightPadding();
138 return q->height() -
q->topPadding() -
q->bottomPadding();
144 qreal oldPadding =
q->topPadding();
151 emit q->topPaddingChanged();
158 qreal oldPadding =
q->leftPadding();
165 emit q->leftPaddingChanged();
172 qreal oldPadding =
q->rightPadding();
179 emit q->rightPaddingChanged();
186 qreal oldPadding =
q->bottomPadding();
193 emit q->bottomPaddingChanged();
206void QQuickText::q_updateLayout()
215 if (!
q->isComponentComplete()) {
232 bool fontSizeModified =
false;
257 cursor.mergeBlockFormat(blockFormat);
290 for (
auto it =
d->extra->pixmapsInProgress.
cbegin();
it !=
d->extra->pixmapsInProgress.
cend();) {
292 if (job->url() ==
url) {
293 if (job->isError()) {
299 qCDebug(lcText) <<
"already downloading" <<
url;
301 return job->isReady() ? job->image() :
QVariant();
311 p->connectFinished(
this,
SLOT(resourceRequestFinished()));
312 d->extra->pixmapsInProgress.append(
p);
314 return p->isReady() ?
p->image() :
QVariant();
320void QQuickText::resourceRequestFinished()
324 for (
auto it =
d->extra->pixmapsInProgress.
cbegin();
it !=
d->extra->pixmapsInProgress.
cend();) {
326 if (job->isError()) {
328 qCDebug(lcText) <<
"failed to load" << job->url();
330 }
else if (job->isReady()) {
334 qCDebug(lcText) << (
res.isValid() ?
"done downloading" :
"failed to load") << job->url();
343 Q_ASSERT(
d->extra->pixmapsInProgress.isEmpty());
351void QQuickText::imageDownloadFinished()
354 if (!
d->extra.isAllocated())
357 if (std::any_of(
d->extra->imgTags.cbegin(),
d->extra->imgTags.cend(),
358 [] (
auto *
image) { return image->pix && image->pix->isLoading(); })) {
369 if (!
img->size.isValid()) {
370 img->size =
img->pix->implicitSize();
376 d->textHasChanged =
true;
390 if (
q->heightValid()) {
397 q->setBaselineOffset(
baseline + yoff +
q->topPadding());
403 const QSizeF contentSize(
q->contentWidth(),
q->contentHeight());
405 if (contentSize != previousSize) {
406 emit q->contentSizeChanged();
407 if (contentSize.
width() != previousSize.
width())
408 emit q->contentWidthChanged(contentSize.
width());
410 emit q->contentHeightChanged(contentSize.
height());
418 if (!
q->isComponentComplete()) {
431 qreal hPadding =
q->leftPadding() +
q->rightPadding();
432 qreal vPadding =
q->topPadding() +
q->bottomPadding();
434 const QSizeF previousSize(
q->contentWidth(),
q->contentHeight());
454 emit q->lineCountChanged();
490 qreal naturalWidth = 0;
496 q->setImplicitWidth(naturalWidth + hPadding);
522 qreal oldWidth =
q->width();
524 if (!
q->widthValid())
525 iWidth =
size.width();
545 firstBlock = firstBlock.
next();
555 (lastLine.y() + lastBlock.
layout()->
position().
y() + lastLine.ascent()) - (firstLine.y() + firstBlock.
layout()->
position().
y() + firstLine.ascent()));
584 m_fullLayoutTextLength =
length;
615 return m_line->
width();
700 const int start,
const int length,
int offset, QVector<QTextLayout::FormatRange> *elidedFormats)
707 if (formatLength > 0) {
709 format.length = formatLength;
710 elidedFormats->append(
format);
723 line.textLength() + nextLine->textLength());
728 elideText[elideText.size() - 1] =
elideChar;
771 emit q->truncatedChanged();
776 emit q->lineCountChanged();
795 if (textOption.
alignment() !=
q->effectiveHAlign()
798 textOption.
setAlignment(Qt::Alignment(
q->effectiveHAlign()));
823 const qreal minimumSize = pixelSize
828 ? qMin<qreal>(minimumSize, largeFont)
830 qreal scaledFontSize = largeFont;
831 const qreal sizeFittingThreshold(0.01);
841 int visibleCount = 0;
858 scaledFont.setPixelSize(scaledFontSize);
860 scaledFont.setPointSizeF(scaledFontSize);
867 bool wrapped =
false;
868 bool truncateHeight =
false;
871 int unwrappedLineCount = 1;
874 qreal naturalHeight = 0;
875 qreal previousHeight = 0;
880 for (visibleCount = 1; ; ++visibleCount) {
883 if (noBreakLastLine && visibleCount == maxLineCount)
890 if (noBreakLastLine && visibleCount == maxLineCount)
893 unelidedRect = br.
united(
line.naturalTextRect());
897 if (multilineElide && naturalHeight > maxHeight && visibleCount > 1) {
904 truncateHeight =
true;
909 elideText = layoutText.at(
line.textStart() - 1) != QChar::LineSeparator
912 elideStart = previousLine.textStart();
919 const bool isLastLine =
line.textStart() +
line.textLength() >= layoutText.
size();
921 if (singlelineElide && visibleCount == 1 &&
line.naturalTextWidth() >
line.width()) {
935 elideStart =
line.textStart();
936 elideEnd = elideStart +
line.textLength();
943 const bool wrappedLine = layoutText.at(
line.textStart() +
line.textLength() - 1) != QChar::LineSeparator;
944 wrapped |= wrappedLine;
947 ++unwrappedLineCount;
950 if (visibleCount == maxLineCount) {
954 if (multilineElide) {
960 elideText = wrappedLine
963 elideStart =
line.textStart();
991 if (layoutText.at(
line.textStart() - 1) == QChar::LineSeparator)
992 ++unwrappedLineCount;
998 const int eol =
line.isValid()
999 ?
line.textStart() +
line.textLength()
1000 : layoutText.
size();
1001 if (eol < layoutText.
size() && layoutText.at(eol) != QChar::LineSeparator)
1003 for (;
line.isValid() && unwrappedLineCount <= maxLineCount; ++unwrappedLineCount)
1012 q->setImplicitSize(naturalWidth +
q->leftPadding() +
q->rightPadding(), naturalHeight +
qMax(
lineHeightOffset(), 0) +
q->topPadding() +
q->bottomPadding());
1027 const qreal oldHeight = maxHeight;
1032 lineWidth =
q->widthValid() &&
q->width() > 0 ? availWidth : naturalWidth;
1033 maxHeight =
q->heightValid() ? availHeight : FLT_MAX;
1038 && (singlelineElide || multilineElide || canWrap || horizontalFit
1048 if ((maxHeight <
qMin(oldHeight, naturalHeight) || (
heightExceeded && maxHeight > oldHeight))
1064 if (
line.isValid()) {
1067 if (!
line.isValid())
1085 const qreal oldHeight = maxHeight;
1089 if ((maxHeight <
qMin(oldHeight, naturalHeight) || (
heightExceeded && maxHeight > oldHeight))
1101 if (eos != -1 && elide) {
1102 int start = eos + 1;
1118 lastLine.y() - firstLine.y());
1123 if (!horizontalFit && !verticalFit)
1131 if (horizontalFit) {
1132 if (unelidedRect.width() >
lineWidth || (!verticalFit && wrapped)) {
1134 largeFont = scaledFontSize;
1136 scaledFontSize = (smallFont + largeFont) / 2;
1139 }
else if (!verticalFit) {
1140 smallFont = scaledFontSize;
1143 if ((largeFont - smallFont) < sizeFittingThreshold)
1146 scaledFontSize = (smallFont + largeFont) / 2;
1151 if (truncateHeight || unelidedRect.height() > maxHeight) {
1153 largeFont = scaledFontSize;
1155 scaledFontSize = (smallFont + largeFont) / 2;
1158 smallFont = scaledFontSize;
1161 if ((largeFont - smallFont) < sizeFittingThreshold)
1164 scaledFontSize = (smallFont + largeFont) / 2;
1180 emit q->fontInfoChanged();
1195 QVector<QTextLayout::FormatRange>
formats;
1208 elideEnd - elideText.size() +
index + 1,
1209 elideText.size() -
index - 1,
1235 br = br.
united(elidedLine.naturalTextRect());
1237 if (visibleCount == 1)
1246 if (firstLine.isValid())
1247 *
baseline = firstLine.y() + firstLine.ascent();
1255 emit q->lineCountChanged();
1259 emit q->truncatedChanged();
1277 qreal totalLineHeight = textHeight;
1279 QList<QQuickStyledTextImgTag *> imagesInLine;
1283 if (
image->position >=
line.textStart() &&
1288 const QUrl url = context->resolvedUrl(
q->baseUrl()).resolved(
image->url);
1291 if (
image->pix->isLoading()) {
1292 image->pix->connectFinished(
q,
SLOT(imageDownloadFinished()));
1293 }
else if (
image->pix->isReady()) {
1294 if (!
image->size.isValid()) {
1300 }
else if (
image->pix->isError()) {
1309 image->pos.setY((textHeight / 2.0) - (ih / 2.0));
1311 image->pos.setY(textHeight - ih);
1312 imagesInLine <<
image;
1319 totalLineHeight =
qMax(totalLineHeight, textTop +
image->pos.y() +
image->size.height());
1320 const int leadX =
line.cursorToX(
image->position);
1322 const bool rtl = trailX < leadX;
1354 doc->setPageSize(
QSizeF(0, 0));
1355 doc->setDocumentMargin(0);
1357 doc->setBaseUrl(context ? context->resolvedUrl(
q->baseUrl()) :
q->baseUrl());
1364#if QT_CONFIG(textmarkdownreader)
1369#if QT_CONFIG(texthtmlparser)
1379 return (
window ?
window->effectiveDevicePixelRatio() :
qApp->devicePixelRatio());
1465 if (
d->extra.isAllocated()) {
1467 d->extra->pixmapsInProgress.clear();
1900 return d->sourceFont;
1906 if (
d->sourceFont ==
font)
1909 d->sourceFont =
font;
1916 if (
d->font.pointSizeF() != -1) {
1919 d->font.setPointSizeF(
size/2.0);
1922 if (oldFont !=
d->font) {
1925 if (
d->formatModifiesFontSize)
1926 d->textHasChanged =
true;
1927 d->implicitWidthValid =
false;
1928 d->implicitHeightValid =
false;
1945 d->implicitWidthValid =
false;
1946 d->implicitHeightValid =
false;
1952 bool needUpdateLayout =
false;
1958 d->implicitWidthValid =
false;
1959 d->implicitHeightValid =
false;
1960 needUpdateLayout =
true;
1963 if (
d->extra.isAllocated()) {
1968 needUpdateLayout =
true;
1973 if (needUpdateLayout)
2008 d->richText =
d->format ==
RichText ||
d->markdownText;
2013 d->updateDocumentText();
2016 d->rightToLeftText =
d->text.isRightToLeft();
2018 d->determineHorizontalAlignment();
2020 d->textHasChanged =
true;
2021 d->implicitWidthValid =
false;
2022 d->implicitHeightValid =
false;
2024 if (
d->extra.isAllocated()) {
2026 d->extra->imgTags.clear();
2065 if (
d->color ==
rgb)
2096 if (
d->linkColor ==
rgb)
2175 if (
d->styleColor ==
rgb)
2178 d->styleColor =
rgb;
2219 bool forceAlign =
d->hAlignImplicit &&
d->effectiveLayoutMirror;
2220 d->hAlignImplicit =
false;
2228 d->hAlignImplicit =
true;
2237 if (!
d->hAlignImplicit &&
d->effectiveLayoutMirror) {
2238 switch (
d->hAlign) {
2249 return effectiveAlignment;
2260 if (oldEffectiveHAlign !=
q->effectiveHAlign())
2261 emit q->effectiveHorizontalAlignmentChanged();
2283 if (
q->isComponentComplete()) {
2286 emit q->effectiveHorizontalAlignmentChanged();
2300 if (
d->vAlign == align)
2338 if (
mode ==
d->wrapMode)
2359 return d->lineCount;
2375 return d->truncated;
2392 return d->maximumLineCount();
2399 d->maximumLineCountValid = lines==INT_MAX ?
false :
true;
2400 if (
d->maximumLineCount() != lines) {
2401 d->extra.value().maximumLineCount = lines;
2402 d->implicitHeightValid =
false;
2412 if (
d->truncated !=
false) {
2413 d->truncated =
false;
2492 bool wasRich =
d->richText;
2498 if (!wasRich &&
d->richText) {
2499 d->updateDocumentText();
2502 d->rightToLeftText =
d->text.isRightToLeft();
2503 d->textHasChanged =
true;
2505 d->determineHorizontalAlignment();
2543 return d->elideMode;
2549 if (
mode ==
d->elideMode)
2552 d->elideMode =
mode;
2584 if (!
d->extra.isAllocated() ||
d->extra->baseUrl.isEmpty()) {
2586 return context->baseUrl();
2590 return d->extra->baseUrl;
2598 d->extra.value().baseUrl =
url;
2602 d->extra->doc->setBaseUrl(
url);
2604 if (
d->styledText) {
2605 d->textHasChanged =
true;
2606 if (
d->extra.isAllocated()) {
2608 d->extra->imgTags.clear();
2640 rect.adjust(-1, 0, 1, 2);
2663 rect.adjust(-1, 0, 1, 2);
2671 if (
d->text.isEmpty()) {
2683 bool widthMaximum = newGeometry.
width() >= oldGeometry.
width() && !
d->widthExceeded;
2684 bool heightMaximum = newGeometry.
height() >= oldGeometry.
height() && !
d->heightExceeded;
2689 goto geomChangeDone;
2698 if (!wrapped && !
elide && !scaleFont && !verticalPositionChanged)
2699 goto geomChangeDone;
2704 goto geomChangeDone;
2707 if (widthMaximum && heightMaximum && !
d->isLineLaidOutConnected() && !verticalPositionChanged)
2708 goto geomChangeDone;
2710 if (!(
widthChanged || widthMaximum) && !
d->isLineLaidOutConnected()) {
2711 if (!verticalPositionChanged) {
2715 goto geomChangeDone;
2717 if (
d->lineCount ==
d->maximumLineCount())
2718 goto geomChangeDone;
2719 }
else if (newGeometry.
height() < oldGeometry.
height()) {
2720 if (
d->lineCount < 2 && !verticalScale && newGeometry.
height() > 0)
2721 goto geomChangeDone;
2725 && !(
d->maximumLineCountValid &&
d->widthExceeded)) {
2726 goto geomChangeDone;
2731 if (oldGeometry.
width() > 0) {
2735 goto geomChangeDone;
2739 if (
d->updateOnComponentComplete ||
d->textHasChanged) {
2751void QQuickText::triggerPreprocess()
2764 if (
d->text.isEmpty()) {
2781 node =
d->sceneGraphContext()->createInternalTextNode(
d->sceneGraphRenderContext());
2802 }
else if (
d->layedOutTextRect.width() > 0) {
2808 int unelidedLineCount =
d->lineCount;
2810 unelidedLineCount -= 1;
2811 if (unelidedLineCount > 0)
2817 if (
d->extra.isAllocated()) {
2819 if (
img->pix &&
img->pix->isReady())
2835 const bool clipNodeChanged =
2836 d->componentComplete &&
d->clipNode() &&
d->clipNode()->rect() !=
clipRect();
2837 if (clipNodeChanged)
2844 d->polishSize =
true;
2846 if (
d->polishSize) {
2848 d->polishSize =
false;
2862 return d->layedOutTextRect.width();
2874 return d->layedOutTextRect.height() +
qMax(
d->lineHeightOffset(), 0);
2889 return d->lineHeight();
2899 d->extra.value().lineHeightValid =
true;
2901 d->implicitHeightValid =
false;
2919 return d->lineHeightMode();
2925 if (
mode ==
d->lineHeightMode())
2928 d->implicitHeightValid =
false;
2929 d->extra.value().lineHeightValid =
true;
2930 d->extra.value().lineHeightMode =
mode;
2974 return d->fontSizeMode();
2980 if (
d->fontSizeMode() ==
mode)
2983 d->polishSize =
true;
2986 d->extra.value().fontSizeMode =
mode;
3003 return d->minimumPixelSize();
3009 if (
d->minimumPixelSize() ==
size)
3013 d->polishSize =
true;
3016 d->extra.value().minimumPixelSize =
size;
3033 return d->minimumPointSize();
3039 if (
d->minimumPointSize() ==
size)
3043 d->polishSize =
true;
3046 d->extra.value().minimumPointSize =
size;
3056 if (
d->richText &&
d->extra.isAllocated())
3057 return d->extra->pixmapsInProgress.size();
3065 if (
d->updateOnComponentComplete) {
3067 d->updateDocumentText();
3069 d->rightToLeftText =
d->text.isRightToLeft();
3071 d->determineHorizontalAlignment();
3074 if (
d->updateOnComponentComplete)
3086 if (formatRange.format.isAnchor()
3087 && charPos >= formatRange.start
3088 && charPos < formatRange.start + formatRange.length) {
3089 return formatRange.format.anchorHref();
3101 QPointF translatedMousePos = mousePos;
3102 translatedMousePos.
rx() -=
q->leftPadding();
3128 if (
d->isLinkActivatedConnected())
3129 link =
d->anchorAt(
event->position());
3132 event->setAccepted(
false);
3134 d->extra.value().activeLink = link;
3139 if (!
event->isAccepted())
3152 if (
d->isLinkActivatedConnected())
3153 link =
d->anchorAt(
event->position());
3155 if (!link.
isEmpty() &&
d->extra.isAllocated() &&
d->extra->activeLink == link)
3158 event->setAccepted(
false);
3160 if (!
event->isAccepted())
3173 if (formatRange.format.isAnchor()) {
3174 const int start = formatRange.start;
3175 const int len = formatRange.length;
3180 r.setHeight(
line.height());
3186 const QString anchorHref = formatRange.format.anchorHref();
3187 if (anchorName.isEmpty())
3188 anchorName = anchorHref;
3189 links->append( { anchorName, anchorHref,
start,
start +
len,
r.toRect()} );
3196 QVector<QQuickTextPrivate::LinkDesc>
links;
3228 if (
d->extra.isAllocated())
3229 return d->extra->hoveredLink;
3231#if QT_CONFIG(cursor)
3234 return d->anchorAt(
pos);
3261 d->processHoverEvent(
event);
3267 d->processHoverEvent(
event);
3273 d->processHoverEvent(
event);
3279 d->textHasChanged =
true;
3319 return d->renderTypeQuality();
3334 emit renderTypeQualityChanged();
3365 return d->renderType;
3381#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
3382#if QT_DEPRECATED_SINCE(5, 15)
3389void QQuickText::doLayout()
3402void QQuickText::forceLayout()
3433 if (
d->richText &&
d->extra.isAllocated() &&
d->extra->doc !=
nullptr) {
3435 for (block =
d->extra->doc->firstBlock(); block.
isValid(); block = block.
next()) {
3440 if (
d->layout.engine() !=
nullptr)
3441 d->layout.engine()->resetFontEngineCache();
3459 return d->padding();
3468 d->extra.value().padding =
padding;
3470 emit paddingChanged();
3471 if (!
d->extra.isAllocated() || !
d->extra->explicitTopPadding)
3472 emit topPaddingChanged();
3473 if (!
d->extra.isAllocated() || !
d->extra->explicitLeftPadding)
3474 emit leftPaddingChanged();
3475 if (!
d->extra.isAllocated() || !
d->extra->explicitRightPadding)
3476 emit rightPaddingChanged();
3477 if (!
d->extra.isAllocated() || !
d->extra->explicitBottomPadding)
3478 emit bottomPaddingChanged();
3489 if (
d->extra.isAllocated() &&
d->extra->explicitTopPadding)
3490 return d->extra->topPadding;
3491 return d->padding();
3503 d->setTopPadding(0,
true);
3509 if (
d->extra.isAllocated() &&
d->extra->explicitLeftPadding)
3510 return d->extra->leftPadding;
3511 return d->padding();
3523 d->setLeftPadding(0,
true);
3529 if (
d->extra.isAllocated() &&
d->extra->explicitRightPadding)
3530 return d->extra->rightPadding;
3531 return d->padding();
3543 d->setRightPadding(0,
true);
3549 if (
d->extra.isAllocated() &&
d->extra->explicitBottomPadding)
3550 return d->extra->bottomPadding;
3551 return d->padding();
3563 d->setBottomPadding(0,
true);
3627 qmlWarning(
this) <<
"fontInfo: item has no JS engine";
3662#include "moc_qquicktext_p.cpp"
QString anchorAt(const QPointF &pos) const
Returns the reference of the anchor the given position, or an empty string if no anchor exists at tha...
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.
bool isEmpty() const noexcept
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
bool isRightToLeft() const
Returns true if the string is read right to left.
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 setHtml(const QString &html)
Replaces the entire contents of the document with the given HTML-formatted text in the html string.
void setDefaultTextOption(const QTextOption &option)
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QSizeF size
the actual size of the document. This is equivalent to documentLayout()->documentSize();
QTextBlock begin() const
Returns the document's first text block.
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
void setPageSize(const QSizeF &size)
QString toPlainText() const
Returns the plain text contained in the document.
QTextBlock end() const
This function returns a block to test for the end of the document while iterating over it.
QTextBlock firstBlock() const
void setPlainText(const QString &text)
Replaces the entire contents of the document with the given plain text.
QTextBlock lastBlock() const
void setTextWidth(qreal width)
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 qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
QT_BEGIN_NAMESPACE 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