• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QTextLength函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中QTextLength函数的典型用法代码示例。如果您正苦于以下问题:C++ QTextLength函数的具体用法?C++ QTextLength怎么用?C++ QTextLength使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: KoTableStyle

void TestTableCellStyle::testMargin()
{
    QTextTableFormat format1;
    format1.setProperty(QTextFormat::FrameLeftMargin, 4.0);
    format1.setProperty(QTextFormat::FrameRightMargin, 8.0);
    format1.setProperty(QTextFormat::FrameTopMargin, 9.0);
    format1.setProperty(QTextFormat::FrameBottomMargin, 3.0);

    KoTableStyle *style = new KoTableStyle(format1);
    QVERIFY(style);

    QCOMPARE(style->leftMargin(), 4.0);
    QCOMPARE(style->rightMargin(), 8.0);
    QCOMPARE(style->topMargin(), 9.0);
    QCOMPARE(style->bottomMargin(), 3.0);

    style->setLeftMargin(QTextLength(QTextLength::FixedLength, 14.0));
    style->setRightMargin(QTextLength(QTextLength::FixedLength, 18.0));
    style->setTopMargin(QTextLength(QTextLength::FixedLength, 19.0));
    style->setBottomMargin(QTextLength(QTextLength::FixedLength, 13.0));

    QTextTableFormat format2;
    style->applyStyle(format2);

    QCOMPARE(format2.doubleProperty(QTextFormat::FrameLeftMargin), 14.0);
    QCOMPARE(format2.doubleProperty(QTextFormat::FrameRightMargin), 18.0);
    QCOMPARE(format2.doubleProperty(QTextFormat::FrameTopMargin), 19.0);
    QCOMPARE(format2.doubleProperty(QTextFormat::FrameBottomMargin), 13.0);
}
开发者ID:KDE,项目名称:calligra,代码行数:29,代码来源:TestTableCellStyle.cpp


示例2: CalculateTraining

// 4) TRAINING
void ResWaReport::BuildTrainingSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\n\n4) TRAINING & IN-SERVICES\n");

    // VALUES
    int numTrainings;
    int numAttendingTrainings;
    CalculateTraining(numTrainings, numAttendingTrainings);
//    cursor.insertText("\t\t\t# of trainings: " + QString::number(numTrainings) + "\n");
//    cursor.insertText("\t\t\t# attending trainings: " + QString::number(numAttendingTrainings) + "\n");

    QTextTableFormat tableFormat;
    tableFormat.setHeaderRowCount(1);
    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 35);
    constraints << QTextLength(QTextLength::PercentageLength, 35);

    tableFormat.setColumnWidthConstraints(constraints);
    QTextTable *table = cursor.insertTable(2, 2, tableFormat);
    // HEADERS
    TextToCell(table, 0, 0, "# of trainings (observers)", &_tableTextFormat);
    TextToCell(table, 0, 1, "# attending trainings (all people in room)", &_tableTextFormat);
    // VALUES
    TextToCell(table, 1, 0, QString::number(numTrainings), &_tableCellBlue);
    TextToCell(table, 1, 1, QString::number(numAttendingTrainings), &_tableCellBlue);
}
开发者ID:jadmr,项目名称:cpts483_Summer2015_drc,代码行数:29,代码来源:reswareport.cpp


示例3: QCOMPARE

void TestStyles::testStyleInheritance()
{
    KoParagraphStyle style1;
    style1.setTopMargin(QTextLength(QTextLength::FixedLength, 10.0));
    QCOMPARE(style1.topMargin(), 10.0);

    KoParagraphStyle style2;
    style2.setParentStyle(&style1);

    QCOMPARE(style2.topMargin(), 10.0);
    style2.setTopMargin(QTextLength(QTextLength::FixedLength, 20.0));
    QCOMPARE(style2.topMargin(), 20.0);
    QCOMPARE(style1.topMargin(), 10.0);

    style1.setTopMargin(QTextLength(QTextLength::FixedLength, 15.0));
    QCOMPARE(style2.topMargin(), 20.0);
    QCOMPARE(style1.topMargin(), 15.0);

    style2.setTopMargin(QTextLength(QTextLength::FixedLength, 15.0)); // the same, resetting the difference.
    QCOMPARE(style2.topMargin(), 15.0);
    QCOMPARE(style1.topMargin(), 15.0);

    style1.setTopMargin(QTextLength(QTextLength::FixedLength, 12.0)); // parent, so both are affected
    QCOMPARE(style2.topMargin(), 12.0);
    QCOMPARE(style1.topMargin(), 12.0);
}
开发者ID:KDE,项目名称:calligra,代码行数:26,代码来源:TestStyles.cpp


示例4: KoTableStyle

void TestTableLayout::testTableWidth()
{
    KoTableStyle *tableStyle = new KoTableStyle();
    QVERIFY(tableStyle);
    initTestSimple(2, 2, tableStyle);

    /*
     * Fixed width.
     *
     * Rules:
     *  - Table should have 1 rect.
     *  - Width of this rect should be 60 pt (fixed).
     */
    tableStyle->setWidth(QTextLength(QTextLength::FixedLength, 60.0));
    QTextTableFormat tableFormat = m_table->format();
    tableStyle->applyStyle(tableFormat);
    m_table->setFormat(tableFormat);
    m_layout->layout();
    QCOMPARE(m_textLayout->m_tableLayout.m_tableLayoutData->m_tableRects.size(), 1);
    QCOMPARE(m_textLayout->m_tableLayout.m_tableLayoutData->m_tableRects.at(0).rect.width(), 60.0);

    /*
     * Relative width:
     *
     * Rules:
     *  - Table should have 1 rect.
     *  - Width of this rect should be 80 pt (40% of shape which is 200).
     */
    tableStyle->setWidth(QTextLength(QTextLength::PercentageLength, 40.0));
    tableStyle->applyStyle(tableFormat);
    m_table->setFormat(tableFormat);
    m_layout->layout();
    QCOMPARE(m_textLayout->m_tableLayout.m_tableLayoutData->m_tableRects.size(), 1);
    QCOMPARE(m_textLayout->m_tableLayout.m_tableLayoutData->m_tableRects.at(0).rect.width(), 80.0);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:35,代码来源:TestTableLayout.cpp


示例5: testChangeParent

void TestStyles::testChangeParent()
{
    KoParagraphStyle style1;
    style1.setTopMargin(QTextLength(QTextLength::FixedLength, 10.0));

    KoParagraphStyle style2;
    style2.setTopMargin(QTextLength(QTextLength::FixedLength, 20.0));

    style2.setParentStyle(&style1);
    QCOMPARE(style1.topMargin(), 10.0);
    QCOMPARE(style2.topMargin(), 20.0);

    KoParagraphStyle style3;
    style3.setParentStyle(&style1);
    QCOMPARE(style1.topMargin(), 10.0);
    QCOMPARE(style3.topMargin(), 10.0);

    // test that separating will leave the child with exactly the same dataset
    // as it had before the inheritance
    style3.setParentStyle(0);
    QCOMPARE(style1.topMargin(), 10.0);
    QCOMPARE(style3.topMargin(), 0.0); // we hadn't explicitly set the margin on style3

    // test adding it to another will not destroy any data
    style3.setParentStyle(&style1);
    QCOMPARE(style1.topMargin(), 10.0); // from style1
    QCOMPARE(style2.topMargin(), 20.0); // from style2
    QCOMPARE(style3.topMargin(), 10.0); // inherited from style1

    // Check that style3 now starts following the parent since it does not have
    // the property set
    style3.setParentStyle(&style2);
    QCOMPARE(style3.topMargin(), 20.0); // inherited from style2
}
开发者ID:KDE,项目名称:calligra,代码行数:34,代码来源:TestStyles.cpp


示例6: QTextLength

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 );
}
开发者ID:EPIFIT,项目名称:KDReports,代码行数:51,代码来源:KDReportsFrame.cpp


示例7: testColumnWidthFixed

void TestTableLayout::testColumnWidthFixed()
{
    KoTableStyle *tableStyle = new KoTableStyle;
    tableStyle->setWidth(QTextLength(QTextLength::FixedLength, 150.0));

    setupTest("merged text", "top right text", "mid right text", "bottom left text", "bottom mid text", "bottom right text", tableStyle);
    KoTableColumnAndRowStyleManager styleManager = KoTableColumnAndRowStyleManager::getManager(m_table);

    KoTableColumnStyle column1style;
    column1style.setColumnWidth(2.3);
    styleManager.setColumnStyle(0, column1style);

    KoTableColumnStyle column2style;
    column2style.setColumnWidth(122.5);
    styleManager.setColumnStyle(1, column2style);

    KoTableColumnStyle column3style;
    column3style.setColumnWidth(362.9);
    styleManager.setColumnStyle(2, column3style);

    m_layout->layout();

    QVERIFY(qAbs(QTextCursor(m_table->parentFrame()).block().layout()->lineAt(0).width() - 200.0) < ROUNDING); // table should grow to 200
    QVERIFY(qAbs(mergedCellBlock().layout()->lineAt(0).width() - 124.8) < ROUNDING);
    QVERIFY(qAbs(topRightCellBlock().layout()->lineAt(0).width() - 362.9) < ROUNDING);
    QVERIFY(qAbs(bottomLeftCellBlock().layout()->lineAt(0).width() - 2.3) < ROUNDING);
    QVERIFY(qAbs(bottomMidCellBlock().layout()->lineAt(0).width() - 122.5) < ROUNDING);
    QVERIFY(qAbs(bottomRightCellBlock().layout()->lineAt(0).width() - 362.9) < ROUNDING);
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:29,代码来源:TestTableLayout.cpp


示例8: tableCell

  // TEXTCELL
  void PrinterVisitor::visitTextCellNodeBefore(TextCell *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() );

        if( node->isViewExpression() )
        {
          //view expression table
          QTextTableFormat tableFormatExpression;
          tableFormatExpression.setBorder( 0 );
          tableFormatExpression.setColumns( 1 );
          tableFormatExpression.setCellPadding( 2 );
//          tableFormatExpression.setBackground( QColor(235, 235, 220) ); // 180, 180, 180
          tableFormatExpression.setBackground( QColor(235, 0, 0) ); // 180, 180, 180

          QVector<QTextLength> constraints;
          constraints << QTextLength(QTextLength::PercentageLength, 100);
          tableFormatExpression.setColumnWidthConstraints(constraints);

          cursor.insertTable( 1, 1, tableFormatExpression );
          // QMessageBox::information(0,"uu2", node->text());

          QString html = node->textHtml();
          cursor.insertFragment( QTextDocumentFragment::fromHtml( html ));
        }
        else
        {
          QString html = node->textHtml();
          html.remove( "file:///" );
          printEditor_->document()->setTextWidth(700);
          cursor.insertFragment(QTextDocumentFragment::fromHtml( html ));
          // QMessageBox::information(0, "uu3", node->text());
        }
      }

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


示例9: if

void DeckListModel::printDeckListNode(QTextCursor *cursor, InnerDecklistNode *node)
{
	static const int totalColumns = 3;

	if (node->height() == 1) {
		QTextBlockFormat blockFormat;
		QTextCharFormat charFormat;
		charFormat.setFontPointSize(11);
		charFormat.setFontWeight(QFont::Bold);
		cursor->insertBlock(blockFormat, charFormat);
		cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)));

		QTextTableFormat tableFormat;
		tableFormat.setCellPadding(0);
		tableFormat.setCellSpacing(0);
		tableFormat.setBorder(0);
		QTextTable *table = cursor->insertTable(node->size() + 1, 2, tableFormat);
		for (int i = 0; i < node->size(); i++) {
			AbstractDecklistCardNode *card = dynamic_cast<AbstractDecklistCardNode *>(node->at(i));

			QTextCharFormat cellCharFormat;
			cellCharFormat.setFontPointSize(9);

			QTextTableCell cell = table->cellAt(i, 0);
			cell.setFormat(cellCharFormat);
			QTextCursor cellCursor = cell.firstCursorPosition();
			cellCursor.insertText(QString("%1 ").arg(card->getNumber()));

			cell = table->cellAt(i, 1);
			cell.setFormat(cellCharFormat);
			cellCursor = cell.firstCursorPosition();
			cellCursor.insertText(card->getName());
		}
	} else if (node->height() == 2) {
		QTextBlockFormat blockFormat;
		QTextCharFormat charFormat;
		charFormat.setFontPointSize(14);
		charFormat.setFontWeight(QFont::Bold);

		cursor->insertBlock(blockFormat, charFormat);
		cursor->insertText(QString("%1: %2").arg(node->getVisibleName()).arg(node->recursiveCount(true)));

		QTextTableFormat tableFormat;
		tableFormat.setCellPadding(10);
		tableFormat.setCellSpacing(0);
		tableFormat.setBorder(0);
		QVector<QTextLength> constraints;
		for (int i = 0; i < totalColumns; i++)
			constraints << QTextLength(QTextLength::PercentageLength, 100.0 / totalColumns);
		tableFormat.setColumnWidthConstraints(constraints);

		QTextTable *table = cursor->insertTable(1, totalColumns, tableFormat);
		for (int i = 0; i < node->size(); i++) {
			QTextCursor cellCursor = table->cellAt(0, (i * totalColumns) / node->size()).lastCursorPosition();
			printDeckListNode(&cellCursor, dynamic_cast<InnerDecklistNode *>(node->at(i)));
		}
	}
	cursor->movePosition(QTextCursor::End);
}
开发者ID:Enoctil,项目名称:cockatrice,代码行数:59,代码来源:decklistmodel.cpp


示例10: CALLS

// 2)  CALLS
void ResWaReport::BuildCallsSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\n\n2) CALLS (Information, Intake, and Referal Calls)\n", _headerFormat);

    cursor.insertBlock();
    cursor.movePosition(QTextCursor::End);
    QTextTableFormat tableFormat;
    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 40);
    constraints << QTextLength(QTextLength::PercentageLength, 40);
    tableFormat.setColumnWidthConstraints(constraints);
    QTextTable *table = cursor.insertTable(1, 2, tableFormat);
    TextToCell(table, 0, 0, "Total calls", &_tableTextFormat);
    TextToCell(table, 0, 1, QString::number(_totalCalls), &_tableCellBlue);
}
开发者ID:jadmr,项目名称:cpts483_Summer2015_drc,代码行数:18,代码来源:reswareport.cpp


示例11: QTextTableFormat

QTextTable *ChatAreaWidget::getMsgTable()
{
    if (tableFrmt == nullptr)
    {
        tableFrmt = new QTextTableFormat();
        tableFrmt->setCellSpacing(2);
        tableFrmt->setBorderStyle(QTextFrameFormat::BorderStyle_None);
        tableFrmt->setColumnWidthConstraints({QTextLength(QTextLength::FixedLength,nameWidth),
                                              QTextLength(QTextLength::FixedLength,2),
                                              QTextLength(QTextLength::PercentageLength,100),
                                              QTextLength(QTextLength::FixedLength,2),
                                              QTextLength(QTextLength::VariableLength,0)});
    }

    QTextCursor tc = textCursor();
    tc.movePosition(QTextCursor::End);
    QTextTable *chatTextTable = tc.insertTable(1, 5, *tableFrmt);

    return chatTextTable;
}
开发者ID:tr37ion,项目名称:qTox,代码行数:20,代码来源:chatareawidget.cpp


示例12: QImage

QImage KoStyleThumbnailer::thumbnail(KoParagraphStyle *style, QSize size, bool recreateThumbnail, KoStyleThumbnailerFlags flags)
{
    if ((flags & UseStyleNameText)  && (!style || style->name().isNull())) {
        return QImage();
    } else if ((! (flags & UseStyleNameText)) && d->thumbnailText.isEmpty()) {
        return QImage();
    }

    if (!size.isValid() || size.isNull()) {
        size = d->defaultSize;
    }
    QString imageKey = "p_" + QString::number(reinterpret_cast<unsigned long>(style)) + "_" + QString::number(size.width()) + "_" + QString::number(size.height());

    if (!recreateThumbnail && d->thumbnailCache.object(imageKey)) {
        return QImage(*(d->thumbnailCache.object(imageKey)));
    }

    QImage *im = new QImage(size.width(), size.height(), QImage::Format_ARGB32_Premultiplied);
    im->fill(QColor(Qt::transparent).rgba());

    KoParagraphStyle *clone = style->clone();
    //TODO: make the following real options
    //we ignore these properties when the thumbnail would not be sufficient to preview properly the whole paragraph with margins.
    clone->setMargin(QTextLength(QTextLength::FixedLength, 0));
    clone->setPadding(0);
    //
    QTextCursor cursor(d->thumbnailHelperDocument);
    cursor.select(QTextCursor::Document);
    cursor.setBlockFormat(QTextBlockFormat());
    cursor.setBlockCharFormat(QTextCharFormat());
    cursor.setCharFormat(QTextCharFormat());
    QTextBlock block = cursor.block();
    clone->applyStyle(block, true);

    QTextCharFormat format;
    // Default to black as text color, to match what KoTextLayoutArea::paint(...)
    // does, setting solid black if no brush is set. Otherwise the UI text color
    // would be used, which might be too bright with dark UI color schemes
    format.setForeground(QColor(Qt::black));
    clone->KoCharacterStyle::applyStyle(format);
    if (flags & UseStyleNameText) {
        cursor.insertText(clone->name(), format);
    } else {
        cursor.insertText(d->thumbnailText, format);
    }
    layoutThumbnail(size, im, flags);

    d->thumbnailCache.insert(imageKey, im);
    delete clone;
    return QImage(*im);
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:51,代码来源:KoStyleThumbnailer.cpp


示例13: QTextLength

void KDReports::AbstractTableElement::fillTableFormat( QTextTableFormat& tableFormat, QTextCursor& textDocCursor ) const
{
    if ( d->m_width ) {
        if ( d->m_unit == Millimeters ) {
            tableFormat.setWidth( QTextLength( QTextLength::FixedLength, mmToPixels( d->m_width ) ) );
        } else {
            tableFormat.setWidth( QTextLength( QTextLength::PercentageLength, d->m_width ) );
        }
    }

    tableFormat.setBorder( border() );
#if QT_VERSION >= 0x040300
    tableFormat.setBorderBrush( borderBrush() );
    tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid );
#endif
    tableFormat.setCellPadding( mmToPixels( padding() ) );
    tableFormat.setCellSpacing( -1 ); // HTML-like table borders look so old century
    if ( d->m_fontSpecified ) {
        QTextCharFormat charFormat = textDocCursor.charFormat();
        charFormat.setFont( d->m_defaultFont );
        textDocCursor.setCharFormat( charFormat );
    }
}
开发者ID:naufraghi,项目名称:KDReports,代码行数:23,代码来源:KDReportsAbstractTableElement.cpp


示例14: ignore_

  /*!
   * \author Anders Fernström
   * \date 2005-12-19
   *
   * \brief The class constructor
   *
   * 2006-03-03 AF, Updated function so cells are printed in tables,
   * so chapter numbers can be added to the left of the text. This
   * change remade large part of this function (and the rest of the
   * class).
   */
  PrinterVisitor::PrinterVisitor( QTextDocument* doc, QPrinter* printer )
    : ignore_(false), firstChild_(true), closedCell_(0), currentTableRow_(0), printer_(printer)
  {
    printEditor_ = new QTextEdit();
    printEditor_->setDocument( doc );



    // set table format
    QTextTableFormat tableFormat;
    tableFormat.setBorder( 0 );
    tableFormat.setColumns( 2 );
    tableFormat.setCellPadding( 5 );

    QVector<QTextLength> constraints;
        constraints << QTextLength(QTextLength::FixedLength, 50)
                    << QTextLength(QTextLength::VariableLength, 620);
        tableFormat.setColumnWidthConstraints(constraints);

    // insert the table
    QTextCursor cursor = printEditor_->textCursor();
    table_ = cursor.insertTable(1, 2, tableFormat);

  }
开发者ID:adrpo,项目名称:OMNotebook,代码行数:35,代码来源:printervisitor.cpp


示例15: QTextLength

void CreateBlogMsg::addPostSplitter()
{
    QTextBlockFormat f = ui.msgEdit->textCursor().blockFormat();
    QTextBlockFormat f1 = f;

    f.setProperty( TextFormat::IsHtmlTagSign, true );
    f.setProperty( QTextFormat::BlockTrailingHorizontalRulerWidth, 
             QTextLength( QTextLength::PercentageLength, 80 ) );
    if ( ui.msgEdit->textCursor().block().text().isEmpty() ) {
        ui.msgEdit->textCursor().mergeBlockFormat( f );
    } else {
        ui.msgEdit->textCursor().insertBlock( f );
    }
    ui.msgEdit->textCursor().insertBlock( f1 );
}
开发者ID:boukeversteegh,项目名称:retroshare,代码行数:15,代码来源:CreateBlogMsg.cpp


示例16: switch

void ParagraphIndentSpacing::save(KoParagraphStyle *style)
{
    // general note; we have to unset values by setting it to zero instead of removing the item
    // since this dialog may be used on a copy style, which will be applied later. And removing
    // items doesn't work for that.
    if (!m_textIndentInherited){
        style->setTextIndent(QTextLength(QTextLength::FixedLength, widget.first->value()));
    }
    if (!m_leftMarginInherited){
        style->setLeftMargin(QTextLength(QTextLength::FixedLength, widget.left->value()));
    }
    if (!m_rightMarginIngerited){
        style->setRightMargin(QTextLength(QTextLength::FixedLength, widget.right->value()));
    }
    if (!m_topMarginInherited){
        style->setTopMargin(QTextLength(QTextLength::FixedLength, widget.before->value()));
    }
    if (!m_bottomMarginInherited){
        style->setBottomMargin(QTextLength(QTextLength::FixedLength, widget.after->value()));
    }
    if (!m_autoTextIndentInherited){
        style->setAutoTextIndent(widget.autoTextIndent->isChecked());
    }
    if (!m_spacingInherited) {
        style->setLineHeightAbsolute(0); // since it trumps percentage based line heights, unset it.
        style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, 0));
        style->setLineSpacing(0);
        switch (widget.lineSpacing->currentIndex()) {
        case 0: style->setLineHeightPercent(120); break;
        case 1: style->setLineHeightPercent(180); break;
        case 2: style->setLineHeightPercent(240); break;
        case 3: style->setLineHeightPercent(widget.proportional->value()); break;
        case 4:
            if (widget.custom->value() == 0.0) { // then we need to save it differently.
                style->setLineHeightPercent(100);
            } else {
                style->setLineSpacing(widget.custom->value());
            }
            break;
        case 5:
            style->setLineHeightAbsolute(widget.custom->value());
            break;
        case 6:
            style->setMinimumLineHeight(QTextLength(QTextLength::FixedLength, widget.custom->value()));
            break;
        }
        style->setLineSpacingFromFont(widget.lineSpacing->currentIndex() != 5 && widget.useFont->isChecked());
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:49,代码来源:ParagraphIndentSpacing.cpp


示例17: qDebug

//----------fonction de construction du tableau type -------------------------------------------
QTextTableFormat ProduceDoc::myFormat(QTextTableFormat & tableFormat,QString & parametersForTableFormat){
     QTextTableFormat table         = tableFormat;
     QStringList parametersList     = parametersForTableFormat.split(",");
     if (WarnDebugMessage)
              qDebug() << __FILE__ << QString::number(__LINE__) << " parametersList.size ="
              << QString::number(parametersList.size()) ;
     tableFormat                     .setBackground(QColor("#C0C0C0"));
     tableFormat                     .setAlignment(Qt::AlignCenter);
     tableFormat                     .setCellPadding(2);
     tableFormat                     .setCellSpacing(2);
     QVector<QTextLength> constraints;
         for(int i = 0;i < parametersList.size() ; i++){
             if (WarnDebugMessage)
              qDebug() << __FILE__ << QString::number(__LINE__) << " parametersForTableFormat =" << parametersList[i] ;
             constraints << QTextLength(QTextLength::FixedLength, parametersList[i].toInt());
             }

     tableFormat                     .setColumnWidthConstraints(constraints);
     return table;
}
开发者ID:eads77m,项目名称:freemedforms,代码行数:21,代码来源:mythread.cpp


示例18: 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 );
    }
开发者ID:KDAB,项目名称:KDReports,代码行数:39,代码来源:KDReportsTextDocumentData.cpp


示例19: QDialog

/** "Help message" or "About" dialog box */
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
    QDialog(parent),
    ui(new Ui::HelpMessageDialog)
{
    ui->setupUi(this);

    QString version = tr("Beardcoin Core") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion());
    /* On x86 add a bit specifier to the version so that users can distinguish between
     * 32 and 64 bit builds. On other architectures, 32/64 bit may be more ambigious.
     */
#if defined(__x86_64__)
    version += " " + tr("(%1-bit)").arg(64);
#elif defined(__i386__ )
    version += " " + tr("(%1-bit)").arg(32);
#endif

    if (about)
    {
        setWindowTitle(tr("About Beardcoin Core"));

        /// HTML-format the license message from the core
        QString licenseInfo = QString::fromStdString(LicenseInfo());
        QString licenseInfoHTML = licenseInfo;
        // Make URLs clickable
        QRegExp uri("<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2);
        uri.setMinimal(true); // use non-greedy matching
        licenseInfoHTML.replace(uri, "<a href=\"\\1\">\\1</a>");
        // Replace newlines with HTML breaks
        licenseInfoHTML.replace("\n\n", "<br><br>");

        ui->aboutMessage->setTextFormat(Qt::RichText);
        ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
        text = version + "\n" + licenseInfo;
        ui->aboutMessage->setText(version + "<br><br>" + licenseInfoHTML);
        ui->aboutMessage->setWordWrap(true);
        ui->helpMessage->setVisible(false);
    } else {
        setWindowTitle(tr("Command-line options"));
        QString header = tr("Usage:") + "\n" +
                         "  beardcoin-qt [" + tr("command-line options") + "]                     " + "\n";
        QTextCursor cursor(ui->helpMessage->document());
        cursor.insertText(version);
        cursor.insertBlock();
        cursor.insertText(header);
        cursor.insertBlock();

        QString coreOptions = QString::fromStdString(HelpMessage(HMM_BITCOIN_QT));
        text = version + "\n" + header + "\n" + coreOptions;

        QTextTableFormat tf;
        tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);
        tf.setCellPadding(2);
        QVector<QTextLength> widths;
        widths << QTextLength(QTextLength::PercentageLength, 35);
        widths << QTextLength(QTextLength::PercentageLength, 65);
        tf.setColumnWidthConstraints(widths);

        QTextCharFormat bold;
        bold.setFontWeight(QFont::Bold);

        Q_FOREACH (const QString &line, coreOptions.split("\n")) {
            if (line.startsWith("  -"))
            {
                cursor.currentTable()->appendRows(1);
                cursor.movePosition(QTextCursor::PreviousCell);
                cursor.movePosition(QTextCursor::NextRow);
                cursor.insertText(line.trimmed());
                cursor.movePosition(QTextCursor::NextCell);
            } else if (line.startsWith("   ")) {
                cursor.insertText(line.trimmed()+' ');
            } else if (line.size() > 0) {
                //Title of a group
                if (cursor.currentTable())
                    cursor.currentTable()->appendRows(1);
                cursor.movePosition(QTextCursor::Down);
                cursor.insertText(line.trimmed(), bold);
                cursor.insertTable(1, 2, tf);
            }
        }

        ui->helpMessage->moveCursor(QTextCursor::Start);
        ui->scrollArea->setVisible(false);
        ui->aboutLogo->setVisible(false);
    }
}
开发者ID:jn2840,项目名称:bitcoin,代码行数:86,代码来源:utilitydialog.cpp


示例20: lock

void CDiaryEdit::draw(QTextDocument& doc)
{
    CDiaryEditLock lock(this);
    QFontMetrics fm(QFont(font().family(),10));

    bool hasGeoCaches = false;
    int cnt;
    int w = doc.textWidth();
    int pointSize = ((10 * (w - 2 * ROOT_FRAME_MARGIN)) / (CHAR_PER_LINE *  fm.width("X")));

    if(pointSize == 0) return;

    doc.setUndoRedoEnabled(false);

    QFont f = textEdit->font();
    f.setPointSize(pointSize);
    textEdit->setFont(f);

    QTextCharFormat fmtCharHeading1;
    fmtCharHeading1.setFont(f);
    fmtCharHeading1.setFontWeight(QFont::Black);
    fmtCharHeading1.setFontPointSize(f.pointSize() + 8);

    QTextCharFormat fmtCharHeading2;
    fmtCharHeading2.setFont(f);
    fmtCharHeading2.setFontWeight(QFont::Black);
    fmtCharHeading2.setFontPointSize(f.pointSize() + 4);

    QTextCharFormat fmtCharStandard;
    fmtCharStandard.setFont(f);

    QTextCharFormat fmtCharHeader;
    fmtCharHeader.setFont(f);
    fmtCharHeader.setBackground(Qt::darkBlue);
    fmtCharHeader.setFontWeight(QFont::Bold);
    fmtCharHeader.setForeground(Qt::white);

    QTextBlockFormat fmtBlockStandard;
    fmtBlockStandard.setTopMargin(10);
    fmtBlockStandard.setBottomMargin(10);
    fmtBlockStandard.setAlignment(Qt::AlignJustify);

    QTextFrameFormat fmtFrameStandard;
    fmtFrameStandard.setTopMargin(5);
    fmtFrameStandard.setBottomMargin(5);
    fmtFrameStandard.setWidth(w - 2 * ROOT_FRAME_MARGIN);

    QTextFrameFormat fmtFrameRoot;
    fmtFrameRoot.setTopMargin(ROOT_FRAME_MARGIN);
    fmtFrameRoot.setBottomMargin(ROOT_FRAME_MARGIN);
    fmtFrameRoot.setLeftMargin(ROOT_FRAME_MARGIN);
    fmtFrameRoot.setRightMargin(ROOT_FRAME_MARGIN);

    QTextTableFormat fmtTableStandard;
    fmtTableStandard.setBorder(1);
    fmtTableStandard.setBorderBrush(Qt::black);
    fmtTableStandard.setCellPadding(4);
    fmtTableStandard.setCellSpacing(0);
    fmtTableStandard.setHeaderRowCount(1);
    fmtTableStandard.setTopMargin(10);
    fmtTableStandard.setBottomMargin(20);
    fmtTableStandard.setWidth(w - 2 * ROOT_FRAME_MARGIN);

    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::FixedLength, 32);
    constraints << QTextLength(QTextLength::VariableLength, 50);
    constraints << QTextLength(QTextLength::VariableLength, 100);
    fmtTableStandard.setColumnWidthConstraints(constraints);

    doc.rootFrame()->setFrameFormat(fmtFrameRoot);
    QTextCursor cursor = doc.rootFrame()->firstCursorPosition();

    cursor.insertText(diary.getName(), fmtCharHeading1);
    cursor.setCharFormat(fmtCharStandard);
    cursor.setBlockFormat(fmtBlockStandard);

    diary.diaryFrame = cursor.insertFrame(fmtFrameStandard);
    {
        QTextCursor cursor1(diary.diaryFrame);

        cursor1.setCharFormat(fmtCharStandard);
        cursor1.setBlockFormat(fmtBlockStandard);

        if(diary.getComment().isEmpty())
        {
            cursor1.insertText(tr("Add your own text here..."));
        }
        else
        {
            cursor1.insertHtml(diary.getComment());
        }
        cursor.setPosition(cursor1.position()+1);
    }

    if(!diary.getWpts().isEmpty())
    {
        QList<CWpt*>& wpts = diary.getWpts();
        cursor.insertText(tr("Waypoints"),fmtCharHeading2);

        QTextTable * table = cursor.insertTable(wpts.count()+1, eMax, fmtTableStandard);
//.........这里部分代码省略.........
开发者ID:Nikoli,项目名称:qlandkartegt,代码行数:101,代码来源:CDiaryEdit.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QTextOption函数代码示例发布时间:2022-05-30
下一篇:
C++ QTextCursor函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap