本文整理汇总了C++中QTextTableFormat::cellPadding方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::cellPadding方法的具体用法?C++ QTextTableFormat::cellPadding怎么用?C++ QTextTableFormat::cellPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableFormat
的用法示例。
在下文中一共展示了QTextTableFormat::cellPadding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cursor
void KDReports::TextDocumentData::scaleFontsBy( qreal factor )
{
QTextCursor cursor( m_document );
qreal currentPointSize = -1.0;
QTextCursor lastCursor( m_document );
Q_FOREVER {
qreal cursorFontPointSize = cursor.charFormat().fontPointSize();
//qDebug() << cursorFontPointSize << "last=" << currentPointSize << cursor.block().text() << "position=" << cursor.position();
if ( cursorFontPointSize != currentPointSize ) {
if ( currentPointSize != -1.0 ) {
setFontSizeHelper( lastCursor, cursor.position() - 1, currentPointSize, factor );
lastCursor.setPosition( cursor.position() - 1, QTextCursor::MoveAnchor );
}
currentPointSize = cursorFontPointSize;
}
if ( cursor.atEnd() )
break;
cursor.movePosition( QTextCursor::NextCharacter );
}
if ( currentPointSize != -1.0 ) {
setFontSizeHelper( lastCursor, cursor.position(), currentPointSize, factor );
}
// Also adjust the padding in the cells so that it remains proportional,
// and the column constraints.
Q_FOREACH( QTextTable* table, m_tables ) {
QTextTableFormat format = table->format();
format.setCellPadding( format.cellPadding() * factor );
QVector<QTextLength> constraints = format.columnWidthConstraints();
for ( int i = 0; i < constraints.size(); ++i ) {
if ( constraints[i].type() == QTextLength::FixedLength ) {
constraints[i] = QTextLength( QTextLength::FixedLength, constraints[i].rawValue() * factor );
}
}
format.setColumnWidthConstraints( constraints );
table->setFormat( format );
}
示例2: emitTable
void HtmlExporter::emitTable( const QTextTable *table )
{
//qDebug() << "emitTable" << html;
QTextTableFormat format = table->format();
html += QLatin1String( "\n<table" );
if ( format.hasProperty( QTextFormat::FrameBorder ) ) {
emitAttribute( "border", QString::number( format.border() ) );
}
emitFloatStyle( format.position() );
emitAlignment( format.alignment() );
emitTextLength( "width", format.width() );
if ( format.hasProperty( QTextFormat::TableCellSpacing ) ) {
emitAttribute( "cellspacing", QString::number( format.cellSpacing() ) );
}
if ( format.hasProperty( QTextFormat::TableCellPadding ) ) {
emitAttribute( "cellpadding", QString::number( format.cellPadding() ) );
}
QBrush bg = format.background();
if ( bg != Qt::NoBrush ) {
emitAttribute( "bgcolor", bg.color().name() );
}
html += QLatin1Char( '>' );
const int rows = table->rows();
const int columns = table->columns();
QVector<QTextLength> columnWidths = format.columnWidthConstraints();
if ( columnWidths.isEmpty() ) {
columnWidths.resize( columns );
columnWidths.fill( QTextLength() );
}
// Q_ASSERT(columnWidths.count() == columns);
QVarLengthArray<bool> widthEmittedForColumn( columns );
for ( int i = 0; i < columns; ++i ) {
widthEmittedForColumn[i] = false;
}
const int headerRowCount = qMin( format.headerRowCount(), rows );
if ( headerRowCount > 0 ) {
html += QLatin1String( "<thead>" );
}
for ( int row = 0; row < rows; ++row ) {
html += QLatin1String( "\n<tr>" );
for ( int col = 0; col < columns; ++col ) {
const QTextTableCell cell = table->cellAt( row, col );
// for col/rowspans
if ( cell.row() != row ) {
continue;
}
if ( cell.column() != col ) {
continue;
}
html += QLatin1String( "\n<td" );
if ( !widthEmittedForColumn[col] ) {
emitTextLength( "width", columnWidths.at( col ) );
widthEmittedForColumn[col] = true;
}
if ( cell.columnSpan() > 1 ) {
emitAttribute( "colspan", QString::number( cell.columnSpan() ) );
}
if ( cell.rowSpan() > 1 ) {
emitAttribute( "rowspan", QString::number( cell.rowSpan() ) );
}
const QTextCharFormat cellFormat = cell.format();
QBrush bg = cellFormat.background();
if ( bg != Qt::NoBrush ) {
emitAttribute( "bgcolor", bg.color().name() );
}
html += QLatin1Char( '>' );
emitFrame( cell.begin() );
html += QLatin1String( "</td>" );
}
html += QLatin1String( "</tr>" );
if ( headerRowCount > 0 && row == headerRowCount - 1 ) {
html += QLatin1String( "</thead>" );
}
}
html += QLatin1String( "</table>" );
}