本文整理汇总了C++中QTextFormat::type方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextFormat::type方法的具体用法?C++ QTextFormat::type怎么用?C++ QTextFormat::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextFormat
的用法示例。
在下文中一共展示了QTextFormat::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: convertFormatIndex
int QTextCopyHelper::convertFormatIndex(const QTextFormat &oldFormat, int objectIndexToSet)
{
QTextFormat fmt = oldFormat;
if (objectIndexToSet != -1) {
fmt.setObjectIndex(objectIndexToSet);
} else if (fmt.objectIndex() != -1) {
int newObjectIndex = objectIndexMap.value(fmt.objectIndex(), -1);
if (newObjectIndex == -1) {
QTextFormat objFormat = src->formatCollection()->objectFormat(fmt.objectIndex());
Q_ASSERT(objFormat.objectIndex() == -1);
newObjectIndex = formatCollection.createObjectIndex(objFormat);
objectIndexMap.insert(fmt.objectIndex(), newObjectIndex);
}
fmt.setObjectIndex(newObjectIndex);
}
int idx = formatCollection.indexForFormat(fmt);
Q_ASSERT(formatCollection.format(idx).type() == oldFormat.type());
return idx;
}