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


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

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


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

示例1: visitLatexCellNodeBefore

  void PrinterVisitor::visitLatexCellNodeBefore(LatexCell *node)
  {
    if( !ignore_ || firstChild_ )
    {

      ++currentTableRow_;
      table_->insertRows( currentTableRow_, 1 );

      // first column
      QTextTableCell tableCell( table_->cellAt( currentTableRow_, 0 ) );
      if( tableCell.isValid() )
      {
        if( !node->ChapterCounterHtml().isNull() )
        {
          QTextCursor cursor( tableCell.firstCursorPosition() );
          cursor.insertFragment( QTextDocumentFragment::fromHtml(
            node->ChapterCounterHtml() ));
        }
      }

      // second column
      tableCell = table_->cellAt( currentTableRow_, 1 );
      if( tableCell.isValid() )
      {
        QTextCursor cursor( tableCell.firstCursorPosition() );

        // input table
        QTextTableFormat tableFormatInput;
        tableFormatInput.setBorder( 0 );
        tableFormatInput.setMargin( 6 );
        tableFormatInput.setColumns( 1 );
        tableFormatInput.setCellPadding( 8 );
        tableFormatInput.setBackground( QColor(245, 245, 255) ); // 200, 200, 255
        QVector<QTextLength> constraints;
        constraints << QTextLength(QTextLength::PercentageLength, 100);
                tableFormatInput.setColumnWidthConstraints(constraints);
        cursor.insertTable( 1, 1, tableFormatInput );

        QString html = node->textHtml();
        html += "<br>";
        if( !node->isEvaluated() || node->isClosed() )
          html += "<br>";
        cursor.insertFragment( QTextDocumentFragment::fromHtml( html ));

        if( node->isEvaluated() && !node->isClosed() )
        {
          QTextTableFormat tableFormatOutput;
          tableFormatOutput.setBorder( 0 );
          tableFormatOutput.setMargin( 6 );
          tableFormatOutput.setColumns( 1 );
          tableFormatOutput.setCellPadding( 8 );
          QVector<QTextLength> constraints;
          constraints << QTextLength(QTextLength::PercentageLength, 100);
          tableFormatOutput.setColumnWidthConstraints(constraints);

          cursor = tableCell.lastCursorPosition();
          cursor.insertTable( 1, 1, tableFormatOutput );

          QString outputHtml( node->textOutputHtml() );
          outputHtml += "<br><br>";


          outputHtml.remove( "file:///" );
          cursor.insertFragment( QTextDocumentFragment::fromHtml( outputHtml ));
        }

      }

      if( firstChild_ )
        firstChild_ = false;
    }
  }
开发者ID:adrpo,项目名称:OMNotebook,代码行数:72,代码来源:printervisitor.cpp

示例2: writeTable

    bool OutputQtDocument::writeTable()
    {
        /*
            start of table
        */
        m_cursor.beginEditBlock();

        m_cursor.insertBlock();
        m_cursor.insertBlock();
        QTextFrame *topFrame = m_cursor.currentFrame();

        QTextTableFormat tableFormat;
        tableFormat.setCellPadding(4);
        tableFormat.setHeaderRowCount(1);
        /* tableFormat.setBorderStyle(
                QTextFrameFormat::BorderStyle_Double); */
        tableFormat.setMargin(2);
        tableFormat.setWidth(QTextLength(
                QTextLength::PercentageLength, 100));

        QTextTable *table = m_cursor.insertTable(
                m_params->height()+2, m_params->width()+5, tableFormat);

        /*
            headers
        */
        m_cursor = table->cellAt(0, 0).firstCursorPosition();
        m_cursor.insertText("i");
        m_cursor = table->cellAt(0, 1).firstCursorPosition();
        m_cursor.insertText(tr("basis"));
        m_cursor = table->cellAt(0, 2).firstCursorPosition();
        m_cursor.insertHtml("C<sub>i</sub> ");
        m_cursor = table->cellAt(0, 3).firstCursorPosition();
        m_cursor.insertText("B");

        for(size_t j=0; j < m_params->width(); j++)
        {
            m_cursor = table->cellAt(0, j+4).firstCursorPosition();
            m_cursor.insertHtml(QString("P<sub>%1</sub> ").arg(j+1));
            /* m_cursor.insertHtml(QString("C<sub>%1</sub> =").arg(j+1));
            if(m_params->variableType(j) == SimplexMethod::VariableArtificial)
                m_cursor.insertText("W");
            else
                m_cursor.insertText(formatDouble(m_params->rowC(j))); */

        }

        m_cursor = table->cellAt(0, m_params->width()+4).firstCursorPosition();
        m_cursor.insertText(QChar(0x0398)); // theta

        /*
            matrix, columnCompareOp, columnB, columnTheta
        */
        for(size_t i=0; i < m_params->height(); i++)
        {
            m_cursor = table->cellAt(i+1, 0).firstCursorPosition();
            m_cursor.insertText(QString("%1").arg(i+1));

            // basis
            m_cursor = table->cellAt(i+1, 1).firstCursorPosition();
            size_t basisColumn = m_params->columnBasis(i);
            m_cursor.insertHtml(QString("P<sub>%1</sub> ").arg(basisColumn+1));

            // basis C
            m_cursor = table->cellAt(i+1, 2).firstCursorPosition();
            if(m_params->variableType(basisColumn) == SimplexMethod::VariableArtificial)
                m_cursor.insertText("W");
            else
                m_cursor.insertText(formatDouble(m_params->rowC(basisColumn)));

            // B
            m_cursor = table->cellAt(i+1, 3).firstCursorPosition();
            m_cursor.insertText(formatDouble(m_params->columnB(i)));

            // matrix
            for(size_t j=0; j < m_params->width(); j++)
            {
                m_cursor = table->cellAt(i+1, j+4).firstCursorPosition();
                m_cursor.insertText(formatDouble(m_params->matrixA(i, j)));
            }

            // theta
            m_cursor = table->cellAt(i+1, m_params->width()+4).firstCursorPosition();
            if(m_params->columnTheta(i) > 0)
                 m_cursor.insertText(formatDouble(m_params->columnTheta(i)));
            else
                 m_cursor.insertText("-");
        }

        /*
            m+1 row
        */
        m_cursor = table->cellAt(m_params->height()+1, 0).firstCursorPosition();
        m_cursor.insertText("m+1");
        m_cursor = table->cellAt(m_params->height()+1, 3).firstCursorPosition();
        m_cursor.insertText(formatDouble(m_params->F()));

        for(size_t j=0; j < m_params->width(); j++)
        {
            m_cursor = table->cellAt(m_params->height()+1, j+4).firstCursorPosition();
//.........这里部分代码省略.........
开发者ID:rtsisyk,项目名称:simplexsolver,代码行数:101,代码来源:outputqtdocument.cpp


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