本文整理汇总了C++中QTextLayout::text方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextLayout::text方法的具体用法?C++ QTextLayout::text怎么用?C++ QTextLayout::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextLayout
的用法示例。
在下文中一共展示了QTextLayout::text方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: longString
void tst_qquickstyledtext::longString()
{
QTextLayout layout;
QList<QQuickStyledTextImgTag*> imgTags;
bool fontSizeModified = false;
QString input(9999999, QChar('.'));
QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified);
QCOMPARE(layout.text(), input);
input = QString(9999999, QChar('\t')); // whitespace
QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified);
QCOMPARE(layout.text(), QString(""));
}
示例2: textOutput
void tst_qquickstyledtext::textOutput()
{
QFETCH(QString, input);
QFETCH(QString, output);
QFETCH(FormatList, formats);
QFETCH(bool, modifiesFontSize);
QTextLayout layout;
QList<QQuickStyledTextImgTag*> imgTags;
bool fontSizeModified = false;
QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified);
QCOMPARE(layout.text(), output);
QList<QTextLayout::FormatRange> layoutFormats = layout.additionalFormats();
QCOMPARE(layoutFormats.count(), formats.count());
for (int i = 0; i < formats.count(); ++i) {
QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
if (formats.at(i).type & Format::Bold)
QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Bold);
else
QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Normal);
QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic));
QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline));
}
QCOMPARE(fontSizeModified, modifiesFontSize);
}
示例3: textOutput
void tst_qdeclarativestyledtext::textOutput()
{
QFETCH(QString, input);
QFETCH(QString, output);
QTextLayout layout;
QDeclarativeStyledText::parse(input, layout);
QCOMPARE(layout.text(), output);
}
示例4: viewItemTextLayout
// Origin: Qt
static void viewItemTextLayout(QTextLayout &textLayout, int lineWidth, qreal &height,
qreal &widthUsed)
{
height = 0;
widthUsed = 0;
textLayout.beginLayout();
QString str = textLayout.text();
while (true)
{
QTextLine line = textLayout.createLine();
if (!line.isValid())
break;
if (line.textLength() == 0)
break;
line.setLineWidth(lineWidth);
line.setPosition(QPointF(0, height));
height += line.height();
widthUsed = qMax(widthUsed, line.naturalTextWidth());
}
textLayout.endLayout();
}
示例5: anchors
void tst_qquickstyledtext::anchors()
{
QFETCH(QString, input);
QFETCH(QString, output);
QFETCH(FormatList, formats);
QTextLayout layout;
QList<QQuickStyledTextImgTag*> imgTags;
bool fontSizeModified = false;
QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified);
QCOMPARE(layout.text(), output);
QList<QTextLayout::FormatRange> layoutFormats = layout.additionalFormats();
QCOMPARE(layoutFormats.count(), formats.count());
for (int i = 0; i < formats.count(); ++i) {
QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
QVERIFY(layoutFormats.at(i).format.isAnchor() == bool(formats.at(i).type & Format::Anchor));
}
}