本文整理汇总了C++中QTextFrameFormat::leftMargin方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextFrameFormat::leftMargin方法的具体用法?C++ QTextFrameFormat::leftMargin怎么用?C++ QTextFrameFormat::leftMargin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextFrameFormat
的用法示例。
在下文中一共展示了QTextFrameFormat::leftMargin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: c
void KDReports::TextDocumentData::updatePercentSizes( const QSizeF& size )
{
QTextCursor c( m_document );
c.beginEditBlock();
// TODO only if we inserted resizable images
do {
c.movePosition( QTextCursor::NextCharacter );
QTextCharFormat format = c.charFormat();
if ( format.hasProperty( ResizableImageProperty ) ) {
Q_ASSERT( format.isImageFormat() );
QTextImageFormat imageFormat = format.toImageFormat();
updatePercentSize( imageFormat, size );
//qDebug() << "updatePercentSizes: setting image to " << imageFormat.width() << "," << imageFormat.height();
c.movePosition( QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor );
c.setCharFormat( imageFormat );
c.movePosition( QTextCursor::NextCharacter );
}
} while ( !c.atEnd() );
if (m_usesTabPositions) {
QTextFrameFormat rootFrameFormat = m_document->rootFrame()->frameFormat();
const int rootFrameMargins = rootFrameFormat.leftMargin() + rootFrameFormat.rightMargin();
QTextBlock block = m_document->firstBlock();
do {
QTextBlockFormat blockFormat = block.blockFormat();
QList<QTextOption::Tab> tabs = blockFormat.tabPositions();
//qDebug() << "Looking at block" << block.blockNumber() << "tabs:" << tabs.count();
if (!tabs.isEmpty()) {
for (int i = 0; i < tabs.count(); ++i) {
QTextOption::Tab& tab = tabs[i];
if ( tab.delimiter == QLatin1Char('P') /* means Page -- see rightAlignedTab*/) {
if ( tab.type == QTextOption::RightTab ) {
//qDebug() << "Adjusted RightTab from" << tab.position << "to" << size.width();
tab.position = size.width() - rootFrameMargins;
} else if ( tab.type == QTextOption::CenterTab ) {
tab.position = ( size.width() - rootFrameMargins ) / 2;
}
}
}
blockFormat.setTabPositions( tabs );
//qDebug() << "Adjusted tabs:" << tabs;
c.setPosition( block.position() );
c.setBlockFormat( blockFormat );
}
block = block.next();
} while ( block.isValid() );
}
c.endEditBlock();
}
示例2: addFrameDecorations
void QQuickTextNodeEngine::addFrameDecorations(QTextDocument *document, QTextFrame *frame)
{
QTextDocumentLayout *documentLayout = qobject_cast<QTextDocumentLayout *>(document->documentLayout());
QTextFrameFormat frameFormat = frame->format().toFrameFormat();
QTextTable *table = qobject_cast<QTextTable *>(frame);
QRectF boundingRect = table == 0
? documentLayout->frameBoundingRect(frame)
: documentLayout->tableBoundingRect(table);
QBrush bg = frame->frameFormat().background();
if (bg.style() != Qt::NoBrush)
m_backgrounds.append(qMakePair(boundingRect, bg.color()));
if (!frameFormat.hasProperty(QTextFormat::FrameBorder))
return;
qreal borderWidth = frameFormat.border();
if (qFuzzyIsNull(borderWidth))
return;
QBrush borderBrush = frameFormat.borderBrush();
QTextFrameFormat::BorderStyle borderStyle = frameFormat.borderStyle();
if (borderStyle == QTextFrameFormat::BorderStyle_None)
return;
addBorder(boundingRect.adjusted(frameFormat.leftMargin(), frameFormat.topMargin(),
-frameFormat.rightMargin(), -frameFormat.bottomMargin()),
borderWidth, borderStyle, borderBrush);
if (table != 0) {
int rows = table->rows();
int columns = table->columns();
for (int row=0; row<rows; ++row) {
for (int column=0; column<columns; ++column) {
QTextTableCell cell = table->cellAt(row, column);
QRectF cellRect = documentLayout->tableCellBoundingRect(table, cell);
addBorder(cellRect.adjusted(-borderWidth, -borderWidth, 0, 0), borderWidth,
borderStyle, borderBrush);
}
}
}
}
示例3: writeFrameFormat
void QTextOdfWriter::writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat format, int formatIndex) const
{
writer.writeStartElement(styleNS, QString::fromLatin1("style"));
writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("s%1").arg(formatIndex));
writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("section"));
writer.writeEmptyElement(styleNS, QString::fromLatin1("section-properties"));
if (format.hasProperty(QTextFormat::FrameTopMargin))
writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
if (format.hasProperty(QTextFormat::FrameBottomMargin))
writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
if (format.hasProperty(QTextFormat::FrameLeftMargin))
writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin())) );
if (format.hasProperty(QTextFormat::FrameRightMargin))
writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
writer.writeEndElement(); // style
// TODO consider putting the following properties in a qt-namespace.
// Position position () const
// qreal border () const
// QBrush borderBrush () const
// BorderStyle borderStyle () const
// qreal padding () const
// QTextLength width () const
// QTextLength height () const
// PageBreakFlags pageBreakPolicy () const
}