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


C++ QTextCursor::mergeBlockFormat方法代码示例

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


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

示例1: textStyle

void GraphicTextDialog::textStyle(int styleIndex)
{
    QTextCursor cursor = textEdit->textCursor();

    if(styleIndex != 0) {
        QTextListFormat::Style style = QTextListFormat::ListDisc;

        switch (styleIndex) {
            default:
            case 1:
                style = QTextListFormat::ListDisc;
                break;

            case 2:
                style = QTextListFormat::ListCircle;
                break;

            case 3:
                style = QTextListFormat::ListSquare;
                break;

            case 4:
                style = QTextListFormat::ListDecimal;
                break;

            case 5:
                style = QTextListFormat::ListLowerAlpha;
                break;

            case 6:
                style = QTextListFormat::ListUpperAlpha;
                break;
        }

        cursor.beginEditBlock();

        QTextBlockFormat blockFmt = cursor.blockFormat();

        QTextListFormat listFmt;

        if(cursor.currentList()) {
            listFmt = cursor.currentList()->format();
        } else {
            listFmt.setIndent(blockFmt.indent() + 1);
            blockFmt.setIndent(0);
            cursor.setBlockFormat(blockFmt);
        }

        listFmt.setStyle(style);

        cursor.createList(listFmt);

        cursor.endEditBlock();
    } else {
        // ####
        QTextBlockFormat bfmt;
        bfmt.setObjectIndex(-1);
        cursor.mergeBlockFormat(bfmt);
    }
}
开发者ID:damiansimanuk,项目名称:qucs-qt4,代码行数:60,代码来源:graphictextdialog.cpp

示例2: setCurrentOption

void MenuMainScreen::setCurrentOption(QGraphicsSimpleTextItem *option) {
	QBrush whiteBrush(Qt::white);
	QBrush yellowBrush(Qt::yellow);

	if (!!_currentOption)
		_currentOption->setBrush(whiteBrush);

	_currentOption = option;
	_currentOption->setBrush(yellowBrush);

	if (option->text() == QString("Character"))
		_textField->setPlainText("View more information about the selected character.");
	else if (option->text() == QString("Equipment"))
		_textField->setPlainText("View or change the equipment the selected character is wearing.");
	else if (option->text() == QString("Abilities"))
		_textField->setPlainText("View the abilities of the selected character.");
	else if (option->text() == QString("Inventory"))
		_textField->setPlainText("View the items collected by the party.");
	else if (option->text() == QString("Exit"))
		_textField->setPlainText("Exit the menu.");

	QFont font("Times", 12, QFont::Bold);
	_textField->setFont(font);

	QTextBlockFormat format;
	format.setAlignment(Qt::AlignLeft);
	QTextCursor cursor = _textField->textCursor();
	cursor.select(QTextCursor::Document);
	cursor.mergeBlockFormat(format);
	cursor.clearSelection();
	_textField->setTextCursor(cursor);
}
开发者ID:juniordiscart,项目名称:RPGMaker,代码行数:32,代码来源:MenuMainScreen.cpp

示例3: alignCenter

void TextRoom::alignCenter()
{
    QTextBlockFormat fmt;
    QTextCursor tc = textEdit->textCursor();
    fmt.setAlignment(Qt::AlignHCenter);
    tc.mergeBlockFormat(fmt);
}
开发者ID:AlanLZY,项目名称:textroom,代码行数:7,代码来源:textroom.cpp

示例4: setStyle

//段落标号、编号
void MyChild::setStyle(int style)
{
    QTextCursor cursor = this->textCursor();

    if (style != 0) {
        QTextListFormat::Style stylename = QTextListFormat::ListDisc;

        switch (style) {
            default:
            case 1:
                stylename = QTextListFormat::ListDisc;
                break;
            case 2:
                stylename = QTextListFormat::ListCircle;
                break;
            case 3:
                stylename = QTextListFormat::ListSquare;
                break;
            case 4:
                stylename = QTextListFormat::ListDecimal;
                break;
            case 5:
                stylename = QTextListFormat::ListLowerAlpha;
                break;
            case 6:
                stylename = QTextListFormat::ListUpperAlpha;
                break;
            case 7:
                stylename = QTextListFormat::ListLowerRoman;
                break;
            case 8:
                stylename = QTextListFormat::ListUpperRoman;
                break;
        }

        cursor.beginEditBlock();

        QTextBlockFormat blockFmt = cursor.blockFormat();

        QTextListFormat listFmt;

        if (cursor.currentList()) {
            listFmt = cursor.currentList()->format();
        } else {
            listFmt.setIndent(blockFmt.indent() + 1);
            blockFmt.setIndent(0);
            cursor.setBlockFormat(blockFmt);
        }

        listFmt.setStyle(stylename);

        cursor.createList(listFmt);

        cursor.endEditBlock();
    } else {
        QTextBlockFormat bfmt;
        bfmt.setObjectIndex(-1);
        cursor.mergeBlockFormat(bfmt);
    }
}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:61,代码来源:mychild.cpp

示例5: setAlignment

void DocumentHandler::setAlignment(Qt::Alignment a)
{
    QTextBlockFormat fmt;
    fmt.setAlignment((Qt::Alignment) a);
    QTextCursor cursor = QTextCursor(m_doc);
    cursor.setPosition(m_selectionStart, QTextCursor::MoveAnchor);
    cursor.setPosition(m_selectionEnd, QTextCursor::KeepAnchor);
    cursor.mergeBlockFormat(fmt);
    emit alignmentChanged();
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:10,代码来源:documenthandler.cpp

示例6: changeFormatType

void CreateBlogMsg::changeFormatType(int styleIndex )
{
    ui.msgEdit->setFocus( Qt::OtherFocusReason );

    QTextCursor cursor = ui.msgEdit->textCursor();
    //QTextBlockFormat bformat = cursor.blockFormat();
    QTextBlockFormat bformat;
    QTextCharFormat cformat;

    switch (styleIndex) {
         default:
            case 0:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 0 ) );
            cformat.setFontWeight( QFont::Normal );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) );
            break;
        case 1:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 1 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 3 ) );
            break;
        case 2:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 2 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 2 ) );
            break;
        case 3:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 3 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 1 ) );
            break;
        case 4:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 4 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) );
            break;
        case 5:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 5 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( -1 ) );
            break;
        case 6:
            bformat.setProperty( TextFormat::HtmlHeading, QVariant( 6 ) );
            cformat.setFontWeight( QFont::Bold );
            cformat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( -2 ) );
            break;
    }
    //cformat.clearProperty( TextFormat::HasCodeStyle );

    cursor.beginEditBlock();
    cursor.mergeBlockFormat( bformat );
    cursor.select( QTextCursor::BlockUnderCursor );
    cursor.mergeCharFormat( cformat );
    cursor.endEditBlock();
}
开发者ID:boukeversteegh,项目名称:retroshare,代码行数:55,代码来源:CreateBlogMsg.cpp

示例7: reg

QTextDocument *Exporter::prepareTextDoc(QTextDocument *textDoc)
{



    QTextDocument *textDocument = textDoc->clone(this);

    //    textDocument->setDefaultStyleSheet("p, li { white-space: pre-wrap; } p{line-height: 2em; font-family:'Liberation Serif'; font-size:19pt;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:72px;}");

    //cut blank spaces at the begining and end :



    QTextCursor *tCursor = new QTextCursor(textDocument);
    tCursor->movePosition(QTextCursor::Start, QTextCursor::MoveAnchor,1);
    tCursor->movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,1);

    while(tCursor->selectedText() == " "){
        tCursor->deleteChar();
        tCursor->movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,1);
    }

    tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
    tCursor->movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor,1);

    while(tCursor->selectedText() == " "){
        tCursor->deleteChar();
        tCursor->movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor,1);
    }

    //set text config :

    QTextBlockFormat blockFormat;
    //    blockFormat.setBottomMargin(0);
    //    blockFormat.setTopMargin(0);
    //    blockFormat.setTextIndent(72);
    blockFormat.setLineHeight(200, QTextBlockFormat::ProportionalHeight);
    blockFormat.setAlignment(Qt::AlignJustify);
    //    QTextCharFormat charFormat;
    //    charFormat.setFontPointSize(12);
    //    charFormat.setFontFamily("Courrier");

    tCursor->select(QTextCursor::Document);
    tCursor->mergeBlockFormat(blockFormat);
    //    tCursor->mergeBlockCharFormat(charFormat);


    QRegExp reg("-qt-paragraph-type:.*;|margin-top:.*;|margin-bottom:.*;|margin-left:.*;|margin-right:.*;|-qt-block-indent:.*;|text-indent:.*;|font-family:.*;|font-size:.*;");
    reg.setMinimal(true);
    textDocument->setHtml(textDocument->toHtml().remove(reg));



    return textDocument;
}
开发者ID:jacquetc,项目名称:plume-creator-legacy,代码行数:55,代码来源:exporter.cpp

示例8: center

void center(QGraphicsTextItem *item)
{
    QTextBlockFormat format;
    format.setAlignment(Qt::AlignCenter);

    QTextCursor cursor = item->textCursor();
    cursor.select(QTextCursor::Document);
    cursor.mergeBlockFormat(format);
    cursor.clearSelection();
    item->setTextCursor(cursor);
}
开发者ID:jmreyen,项目名称:starfish,代码行数:11,代码来源:storycardscene.cpp

示例9: setAlignment

void MyTextItem::setAlignment(Qt::Alignment alignment)
{
    m_alignment = alignment;
    QTextBlockFormat format;
    format.setAlignment(alignment);
    QTextCursor cursor = textCursor();      // save cursor position
    int position = textCursor().position();
    cursor.select(QTextCursor::Document);
    cursor.mergeBlockFormat(format);
    cursor.clearSelection();
    cursor.setPosition(position);           // restore cursor position
    setTextCursor(cursor);
}
开发者ID:yiqideren,项目名称:kdenlive,代码行数:13,代码来源:graphicsscenerectmove.cpp

示例10: changeAlignment

/*!
 * \brief Changes alignment of the text to the one specified by action \a a
 */
void QwwRichTextEdit::changeAlignment(QAction *a){
    QTextCursor cur = textCursor();
    QTextBlockFormat fmt;
    if(a==al)
      fmt.setAlignment(Qt::AlignLeft);
    else if(a==ar)
      fmt.setAlignment(Qt::AlignRight);
    else if(a==ac)
      fmt.setAlignment(Qt::AlignCenter);
    else if(a==aj)
      fmt.setAlignment(Qt::AlignJustify);
    cur.mergeBlockFormat(fmt);
    setTextCursor(cur);
  }
开发者ID:dewhisna,项目名称:KingJamesPureBibleSearch,代码行数:17,代码来源:qwwrichtextedit.cpp

示例11: changeTextStyleSlot

void TextZone::changeTextStyleSlot(int styleIndex)
{


    QTextBlockFormat blockFormat;
    blockFormat.setBottomMargin(textStyles->blockBottomMarginAt(styleIndex));
    blockFormat.setTextIndent(textStyles->blockFirstLineIndentAt(styleIndex));
    blockFormat.setLeftMargin(textStyles->blockLeftMarginAt(styleIndex));
    blockFormat.setAlignment(textStyles->blockAlignmentTrueNameAt(styleIndex));
    blockFormat.setTopMargin(0);
    blockFormat.setRightMargin(0);
    QTextCharFormat charFormat;
    charFormat.setFontPointSize(textStyles->fontSizeAt(styleIndex));
    charFormat.setFontFamily(textStyles->fontFamilyAt(styleIndex));
    //    charFormat.setFontItalic(textStyles->fontItalicAt(styleIndex));
    //    if (textStyles->fontBoldAt(styleIndex) == true)
    //        charFormat.setFontWeight(75);
    //    else
    //        charFormat.setFontWeight(50);
    //    charFormat.setFontUnderline(textStyles->fontUnderlineAt(styleIndex));
    //    charFormat.setFontStrikeOut(textStyles->fontStrikeOutAt(styleIndex));

    //    charFormat.clearForeground();


    QTextCursor tCursor = this->textCursor();

    // select all of the blocks selected :

    QTextCursor tStartCursor = this->textCursor();
    tStartCursor.setPosition(tCursor.selectionStart());
    tStartCursor.movePosition(QTextCursor::StartOfBlock);
    int startFirstBlock = tStartCursor.position();

    QTextCursor tEndCursor =  this->textCursor();
    tEndCursor.setPosition(tCursor.selectionEnd());
    tEndCursor.movePosition(QTextCursor::EndOfBlock);
    int endLastBlock = tEndCursor.position();

    tCursor.setPosition(startFirstBlock);
    tCursor.setPosition(endLastBlock, QTextCursor::KeepAnchor);


    // merge :
    tCursor.mergeBlockFormat(blockFormat);
    tCursor.mergeCharFormat(charFormat);
    this->mergeCurrentCharFormat(charFormat);

}
开发者ID:jwvdveen,项目名称:plume-creator-legacy,代码行数:49,代码来源:textzone.cpp

示例12: QTextCursor

QTextDocument *Exporter::prepareNoteDoc(QTextDocument *noteDoc)
{
    QTextDocument *textDocument = noteDoc->clone(this);




    //cut blank spaces at the begining and end :



    QTextCursor *tCursor = new QTextCursor(textDocument);
    tCursor->movePosition(QTextCursor::Start, QTextCursor::MoveAnchor,1);
    tCursor->movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,1);

    while(tCursor->selectedText() == " "){
        tCursor->deleteChar();
        tCursor->movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,1);
    }

    tCursor->movePosition(QTextCursor::End, QTextCursor::MoveAnchor,1);
    tCursor->movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor,1);

    while(tCursor->selectedText() == " "){
        tCursor->deleteChar();
        tCursor->movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor,1);
    }

    //set text config :

    QTextBlockFormat blockFormat;
    blockFormat.setBottomMargin(0);
    blockFormat.setTopMargin(0);
    blockFormat.setTextIndent(72);
    blockFormat.setLineHeight(200, QTextBlockFormat::ProportionalHeight);
    blockFormat.setAlignment(Qt::AlignJustify);
    QTextCharFormat charFormat;
    charFormat.setFontPointSize(12);
    charFormat.setFontFamily("Courrier");

    tCursor->select(QTextCursor::Document);
    tCursor->mergeBlockCharFormat(charFormat);
    tCursor->mergeBlockFormat(blockFormat);


    return textDocument;
}
开发者ID:jacquetc,项目名称:plume-creator-legacy,代码行数:47,代码来源:exporter.cpp

示例13: valueChanged

void BattleCharacterStatus::valueChanged(QString name) {
	BattleCharacterItem *character = 0;
	QGraphicsTextItem *infoItem = 0;
	for (int i = 0; i < _characters.size(); i++) {
		BattleCharacterItem *it = _characters.at(i);
		if (!!it && (it->getName() == name)) {
			character = it;
			infoItem = _info.at(i);
			break;
		}
	}

	if (!!character) {
		QString infoString;
		infoString += character->getCharacter()->getName() + QString(":\n");
		infoString += QString("Health: ") + QString::number(character->getHealth().second) + QString(" / ") + QString::number(character->getMaxHealth().second) + QString("\t");
		infoString += QString("Energy: ") + QString::number(character->getEnergy().second) + QString(" / ") + QString::number(character->getMaxEnergy().second);


		double percentage = (double)character->getHealth().second / (double)character->getMaxHealth().second * 100;

		if (percentage > 60)
			infoItem->setDefaultTextColor(Qt::green);
		else if ((percentage <= 60) && (percentage > 25))
			infoItem->setDefaultTextColor(Qt::yellow);
		else if ((percentage <= 25) && (percentage > 0))
			infoItem->setDefaultTextColor(Qt::red);
		else
			infoItem->setDefaultTextColor(Qt::gray);

		infoItem->setPlainText(infoString);
		QFont font("Times", 12, QFont::Bold);
		infoItem->setFont(font);

		QTextBlockFormat format;
		format.setAlignment(Qt::AlignLeft);
		QTextCursor cursor = infoItem->textCursor();
		cursor.select(QTextCursor::Document);
		cursor.mergeBlockFormat(format);
		cursor.clearSelection();
		infoItem->setTextCursor(cursor);
	}
}
开发者ID:juniordiscart,项目名称:RPGMaker,代码行数:43,代码来源:BattleCharacterStatus.cpp

示例14: setCharacters

void BattleCharacterStatus::setCharacters(const QVector<BattleCharacterItem*> &characters) {
	for (int i = 0; i < _info.size(); i++) {
		delete _info.at(i);
	}
	_info.clear();

	_characters = characters;
	int y = 10;
	for (int i = 0; i < _characters.size(); i++) {
		BattleCharacterItem *character = _characters.at(i);
		connect (character, SIGNAL(valueChanged(QString)), this, SLOT(valueChanged(QString)));

		QString infoString;
		infoString += character->getCharacter()->getName() + QString(":\n");
		infoString += QString("Health: ") + QString::number(character->getHealth().second) + QString(" / ") + QString::number(character->getMaxHealth().second) + QString("\t");
		infoString += QString("Energy: ") + QString::number(character->getEnergy().second) + QString(" / ") + QString::number(character->getMaxEnergy().second);

		QGraphicsTextItem *infoItem = new QGraphicsTextItem(this);
		_info.append(infoItem);
		infoItem->setTextWidth(boundingRect().width());
		infoItem->setDefaultTextColor(Qt::green);

		infoItem->setPlainText(infoString);
		QFont font("Times", 12, QFont::Bold);
		infoItem->setFont(font);

		QTextBlockFormat format;
		format.setAlignment(Qt::AlignLeft);
		QTextCursor cursor = infoItem->textCursor();
		cursor.select(QTextCursor::Document);
		cursor.mergeBlockFormat(format);
		cursor.clearSelection();
		infoItem->setTextCursor(cursor);

		infoItem->setPos(10, y);
		y += 50;
	}
}
开发者ID:juniordiscart,项目名称:RPGMaker,代码行数:38,代码来源:BattleCharacterStatus.cpp

示例15: QGraphicsTextItem

TextEffect::TextEffect(MainGraphicsView *view, const QString &text, int duration_ms, const QColor &color) :
    QGraphicsTextItem(text), time_expire(0), view(view) {

    this->setDefaultTextColor(color);
    this->time_expire = game_g->getGameTimeTotalMS() + duration_ms;
    //this->setFont(game_g->getFontStd());
    //this->setFont(game_g->getFontSmall());
    this->setFont(game_g->getFontScene());

    {
        // centre alignment - see http://www.cesarbs.org/blog/2011/05/30/aligning-text-in-qgraphicstextitem/
        this->setTextWidth(this->boundingRect().width());
        QTextBlockFormat format;
        format.setAlignment(Qt::AlignCenter);
        QTextCursor cursor = this->textCursor();
        cursor.select(QTextCursor::Document);
        cursor.mergeBlockFormat(format);
        cursor.clearSelection();
        this->setTextCursor(cursor);
    }

    this->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
}
开发者ID:biddyweb,项目名称:Erebusss,代码行数:23,代码来源:maingraphicsview.cpp


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