本文整理汇总了C++中QTextTableFormat::background方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::background方法的具体用法?C++ QTextTableFormat::background怎么用?C++ QTextTableFormat::background使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTableFormat
的用法示例。
在下文中一共展示了QTextTableFormat::background方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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>" );
}