本文整理汇总了C++中QTextFormat::toCharFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextFormat::toCharFormat方法的具体用法?C++ QTextFormat::toCharFormat怎么用?C++ QTextFormat::toCharFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextFormat
的用法示例。
在下文中一共展示了QTextFormat::toCharFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeFormats
void QTextOdfWriter::writeFormats(QXmlStreamWriter &writer, QSet<int> formats) const
{
writer.writeStartElement(officeNS, QString::fromLatin1("automatic-styles"));
QVector<QTextFormat> allStyles = m_document->allFormats();
QSetIterator<int> formatId(formats);
while(formatId.hasNext()) {
int formatIndex = formatId.next();
QTextFormat textFormat = allStyles.at(formatIndex);
switch (textFormat.type()) {
case QTextFormat::CharFormat:
if (textFormat.isTableCellFormat())
writeTableCellFormat(writer, textFormat.toTableCellFormat(), formatIndex);
else
writeCharacterFormat(writer, textFormat.toCharFormat(), formatIndex);
break;
case QTextFormat::BlockFormat:
writeBlockFormat(writer, textFormat.toBlockFormat(), formatIndex);
break;
case QTextFormat::ListFormat:
writeListFormat(writer, textFormat.toListFormat(), formatIndex);
break;
case QTextFormat::FrameFormat:
writeFrameFormat(writer, textFormat.toFrameFormat(), formatIndex);
break;
case QTextFormat::TableFormat:
;break;
}
}
writer.writeEndElement(); // automatic-styles
}
示例2: toFormat
void tst_QTextFormat::toFormat()
{
{
QTextFormat fmt = QTextFrameFormat();
QCOMPARE(fmt.toFrameFormat().type(), int(QTextFormat::FrameFormat));
}
{
QTextFormat fmt = QTextTableFormat();
QCOMPARE(fmt.toTableFormat().type(), int(QTextFormat::FrameFormat));
QCOMPARE(fmt.toTableFormat().objectType(), int(QTextFormat::TableObject));
}
{
QTextFormat fmt = QTextBlockFormat();
QCOMPARE(fmt.toBlockFormat().type(), int(QTextFormat::BlockFormat));
}
{
QTextFormat fmt = QTextCharFormat();
QCOMPARE(fmt.toCharFormat().type(), int(QTextFormat::CharFormat));
}
{
QTextFormat fmt = QTextListFormat();
QCOMPARE(fmt.toListFormat().type(), int(QTextFormat::ListFormat));
}
}
示例3: drawInlineObject
/*!
\fn void QAbstractTextDocumentLayout::drawInlineObject(QPainter *painter, const QRectF &rect, QTextInlineObject object, int posInDocument, const QTextFormat &format)
This function is called to draw the inline object, \a object, with the
given \a painter within the rectangle specified by \a rect using the
specified text \a format.
\a posInDocument specifies the position of the object within the document.
The default implementation calls drawObject() on the object handlers. This
function is called only within Qt. Subclasses can reimplement this function
to customize the drawing of inline objects.
\sa draw()
*/
void QAbstractTextDocumentLayout::drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item,
int posInDocument, const QTextFormat &format)
{
Q_UNUSED(item);
Q_D(QAbstractTextDocumentLayout);
QTextCharFormat f = format.toCharFormat();
Q_ASSERT(f.isValid());
QTextObjectHandler handler = d->handlers.value(f.objectType());
if (!handler.component)
return;
handler.iface->drawObject(p, rect, document(), posInDocument, format);
}
示例4: resizeInlineObject
/*!
Sets the size of the inline object \a item corresponding to the text
\a format.
\a posInDocument specifies the position of the object within the document.
The default implementation resizes the \a item to the size returned by
the object handler's intrinsicSize() function. This function is called only
within Qt. Subclasses can reimplement this function to customize the
resizing of inline objects.
*/
void QAbstractTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format)
{
Q_D(QAbstractTextDocumentLayout);
QTextCharFormat f = format.toCharFormat();
Q_ASSERT(f.isValid());
QTextObjectHandler handler = d->handlers.value(f.objectType());
if (!handler.component)
return;
QSizeF s = handler.iface->intrinsicSize(document(), posInDocument, format);
item.setWidth(s.width());
item.setAscent(s.height());
item.setDescent(0);
}