当前位置: 首页>>代码示例>>C++>>正文


C++ QTextTableFormat::setProperty方法代码示例

本文整理汇总了C++中QTextTableFormat::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTableFormat::setProperty方法的具体用法?C++ QTextTableFormat::setProperty怎么用?C++ QTextTableFormat::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextTableFormat的用法示例。


在下文中一共展示了QTextTableFormat::setProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fillTableFormat

void KDReports::AutoTableElement::build( ReportBuilder& builder ) const
{
    if( !d->m_tableModel ) {
        return;
    }
    QTextDocument& textDoc = builder.currentDocument();
    QTextCursor& textDocCursor = builder.cursor();
    textDocCursor.beginEditBlock();

    QTextTableFormat tableFormat;
    const int headerRowCount = d->m_horizontalHeaderVisible ? 1 : 0;
    const int headerColumnCount = d->m_verticalHeaderVisible ? 1 : 0;
    tableFormat.setHeaderRowCount( headerRowCount );
    tableFormat.setProperty( KDReports::HeaderColumnsProperty, headerColumnCount );

    tableFormat.setAlignment( textDocCursor.blockFormat().alignment() );
    fillTableFormat( tableFormat, textDocCursor );

    while (d->m_tableModel->canFetchMore(QModelIndex()))
        d->m_tableModel->fetchMore(QModelIndex());

    const int rows = d->m_tableModel->rowCount();
    const int columns = d->m_tableModel->columnCount();

    QTextTable* textTable = textDocCursor.insertTable( rows + headerRowCount,
                                                       columns + headerColumnCount,
                                                       tableFormat );

    QTextCharFormat tableHeaderFormat;
    tableHeaderFormat.setBackground( d->m_headerBackground );
    //qDebug( "rows = %d, columns = %d", textTable->rows(), textTable->columns() );

    if( d->m_horizontalHeaderVisible ) {
        for( int column = 0; column < columns; column++ ) {
            QTextTableCell cell = textTable->cellAt( 0, column + headerColumnCount );
            Q_ASSERT( cell.isValid() );
            cell.setFormat( tableHeaderFormat );
            d->fillCellFromHeaderData( column, Qt::Horizontal, cell, textDoc, textTable, builder );
        }
    }

    if( d->m_verticalHeaderVisible ) {
        for( int row = 0; row < rows; row++ ) {
            QTextTableCell cell = textTable->cellAt( row + headerRowCount, 0 );
            Q_ASSERT( cell.isValid() );
            cell.setFormat( tableHeaderFormat );
            d->fillCellFromHeaderData( row, Qt::Vertical, cell, textDoc, textTable, builder );
        }
    }

    QVector<QBitArray> coveredCells;
    coveredCells.resize(rows);
    for( int row = 0; row < rows; row++ )
        coveredCells[row].resize(columns);

    // The normal data
    for( int row = 0; row < rows; row++ ) {
        for( int column = 0; column < columns; column++ ) {
            if (coveredCells[row].testBit(column))
                continue;
            QTextTableCell cell = textTable->cellAt( row + headerRowCount, column + headerColumnCount );
            Q_ASSERT( cell.isValid() );
            const QSize span = d->fillTableCell( row, column, cell, textDoc, textTable, builder );
            if (span.isValid()) {
                for (int r = row; r < row + span.height() && r < rows; ++r) {
                    for (int c = column; c < column + span.width() && c < columns; ++c) {
                        coveredCells[r].setBit(c);
                    }
                }
            }
        }
    }

    textDocCursor.movePosition( QTextCursor::End );
    textDocCursor.endEditBlock();

    builder.currentDocumentData().registerAutoTable( textTable, this );
}
开发者ID:,项目名称:,代码行数:78,代码来源:


注:本文中的QTextTableFormat::setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。