本文整理汇总了C++中QTextFrameFormat::setHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextFrameFormat::setHeight方法的具体用法?C++ QTextFrameFormat::setHeight怎么用?C++ QTextFrameFormat::setHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextFrameFormat
的用法示例。
在下文中一共展示了QTextFrameFormat::setHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contentsBuilder
void KDReports::Frame::build( ReportBuilder& builder ) const
{
// prepare the frame
QTextFrameFormat format;
if ( d->m_width ) {
if ( d->m_widthUnit == Millimeters ) {
format.setWidth( QTextLength( QTextLength::FixedLength, mmToPixels( d->m_width ) ) );
} else {
format.setWidth( QTextLength( QTextLength::PercentageLength, d->m_width ) );
}
}
if ( d->m_height ) {
if ( d->m_heightUnit == Millimeters ) {
format.setHeight( QTextLength( QTextLength::FixedLength, mmToPixels( d->m_height ) ) );
} else {
format.setHeight( QTextLength( QTextLength::PercentageLength, d->m_height ) );
}
}
format.setPadding( mmToPixels( padding() ) );
format.setBorder( d->m_border );
// TODO borderBrush like in AbstractTableElement
format.setPosition( QTextFrameFormat::InFlow );
QTextCursor& textDocCursor = builder.cursor();
QTextFrame *frame = textDocCursor.insertFrame(format);
QTextCursor contentsCursor = frame->firstCursorPosition();
ReportBuilder contentsBuilder( builder.currentDocumentData(),
contentsCursor, builder.report() );
contentsBuilder.copyStateFrom( builder );
foreach( const KDReports::ElementData& ed, d->m_elements )
{
switch ( ed.m_type ) {
case KDReports::ElementData::Inline:
contentsBuilder.addInlineElement( *ed.m_element );
break;
case KDReports::ElementData::Block:
contentsBuilder.addBlockElement( *ed.m_element, ed.m_align );
break;
case KDReports::ElementData::Variable:
contentsBuilder.addVariable( ed.m_variableType );
break;
}
}
textDocCursor.movePosition( QTextCursor::End );
}
示例2: createPages
void KWQTableView::createPages(QPrinter *printer, QTextDocument *textDoc, bool sendToPrinter)
{
printer->setFullPage(true);
int myDpi = printer->logicalDpiY();
if (Prefs::printStyle() == Prefs::EnumPrintStyle::Flashcard) {
printer->setOrientation(QPrinter::Landscape);
int cardWidth = qRound(5 * qreal(myDpi));
int cardHeight = qRound(3 * qreal(myDpi));
QTextTable *table = textDoc->rootFrame()->lastCursorPosition().insertTable(model()->rowCount(), 2);
QTextTableFormat tableFormat = table->format();
tableFormat.setHeaderRowCount(0);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_None);
tableFormat.setCellSpacing(0);
tableFormat.setCellPadding(0);
QVector<QTextLength> constraints;
constraints.append(QTextLength(QTextLength::FixedLength, cardWidth));
constraints.append(QTextLength(QTextLength::FixedLength, cardWidth));
tableFormat.setColumnWidthConstraints(constraints);
table->setFormat(tableFormat);
QTextBlockFormat headerFormat;
headerFormat.setAlignment(Qt::AlignLeft);
QTextCharFormat headerCharFormat;
headerCharFormat.setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
QTextBlockFormat cellFormat;
cellFormat.setAlignment(Qt::AlignCenter);
QTextCharFormat cellCharFormat;
cellCharFormat.setFont(Prefs::editorFont());
QTextFrameFormat cardFormat;
cardFormat.setBorder(1);
cardFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
cardFormat.setBorderBrush(QBrush(Qt::black));
cardFormat.setWidth(QTextLength(QTextLength::FixedLength, cardWidth));
cardFormat.setHeight(QTextLength(QTextLength::FixedLength, cardHeight));
cardFormat.setPadding(qRound(0.25 * myDpi));
QTextFrameFormat lineFormat;
lineFormat.setBorder(1);
lineFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
lineFormat.setBorderBrush(QBrush(Qt::black));
lineFormat.setWidth(QTextLength(QTextLength::FixedLength, qRound(4.5 * myDpi)));
lineFormat.setHeight(1.1); //1 is drawn as a box whereas this is drawn as a line. Strange...
lineFormat.setPadding(0);
QTextFrame *card;
for (int i = 0; i < model()->rowCount(); i++) {
for (int j = 0; j < model()->columnCount(); j++) {
cardFormat.setPosition(QTextFrameFormat::FloatLeft);
card = table->cellAt(i, j).firstCursorPosition().insertFrame(cardFormat);
card->lastCursorPosition().insertText(model()->headerData(j, Qt::Horizontal, Qt::DisplayRole).toString(), headerCharFormat);
card->lastCursorPosition().insertFrame(lineFormat);
card->lastCursorPosition().insertBlock();
card->lastCursorPosition().insertBlock();
card->lastCursorPosition().insertBlock(cellFormat, cellCharFormat);
card->lastCursorPosition().insertText(model()->data(model()->index(i, j)).toString(), cellCharFormat);
}
}
}
else
{
textDoc->rootFrame()->lastCursorPosition().insertText(QStringLiteral("kwordquiz %1").arg(KWQ_VERSION));
if (Prefs::printStyle() == Prefs::EnumPrintStyle::Exam)
textDoc->rootFrame()->lastCursorPosition().insertText(' ' + i18n("Name:_____________________________ Date:__________"));
QTextTable* table;
if (Prefs::printStyle() == Prefs::EnumPrintStyle::Exam)
table = textDoc->rootFrame()->lastCursorPosition().insertTable(model()->rowCount() + 1, model()->columnCount() + 2);
else
table = textDoc->rootFrame()->lastCursorPosition().insertTable(model()->rowCount() + 1, model()->columnCount() + 1);
QTextTableFormat tableFormat = table->format();
tableFormat.setHeaderRowCount(1);
tableFormat.setBorder(1);
tableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
tableFormat.setCellSpacing(0);
tableFormat.setBorderBrush(QBrush(Qt::black));
tableFormat.setCellPadding(2);
QVector<QTextLength> constraints;
constraints.append(QTextLength(QTextLength::FixedLength, verticalHeader()->width()));
constraints.append(QTextLength(QTextLength::FixedLength, columnWidth(0)));
constraints.append(QTextLength(QTextLength::FixedLength, columnWidth(1)));
if (Prefs::printStyle() == Prefs::EnumPrintStyle::Exam)
constraints.append(QTextLength(QTextLength::FixedLength, 50));
tableFormat.setColumnWidthConstraints(constraints);
table->setFormat(tableFormat);
QTextBlockFormat headerFormat;
//.........这里部分代码省略.........