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


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

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


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

示例1: doTrackBar

void ChatView::doTrackBar()
{
	// save position, because our manipulations could change it
	int scrollbarValue = verticalScrollBar()->value();

	QTextCursor cursor = textCursor();
	cursor.beginEditBlock();
	PsiRichText::Selection selection = PsiRichText::saveSelection(this, cursor);

	//removeTrackBar(cursor);
	if (oldTrackBarPosition) {
		cursor.setPosition(oldTrackBarPosition, QTextCursor::KeepAnchor);
		QTextBlockFormat blockFormat = cursor.blockFormat();
		blockFormat.clearProperty(QTextFormat::BlockTrailingHorizontalRulerWidth);
		cursor.clearSelection();
		cursor.setBlockFormat(blockFormat);
	}

	//addTrackBar(cursor);
	cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
	oldTrackBarPosition = cursor.position();
	QTextBlockFormat blockFormat = cursor.blockFormat();
	blockFormat.setProperty(QTextFormat::BlockTrailingHorizontalRulerWidth, QVariant(true));
	cursor.clearSelection();
	cursor.setBlockFormat(blockFormat);

	PsiRichText::restoreSelection(this, cursor, selection);
	cursor.endEditBlock();
	setTextCursor(cursor);

	verticalScrollBar()->setValue(scrollbarValue);
}
开发者ID:ackbarr,项目名称:psi,代码行数:32,代码来源:chatview_te.cpp

示例2: list

void MRichTextEdit::list(bool checked, QTextListFormat::Style style)
{
    QTextCursor cursor = f_textedit->textCursor();
    cursor.beginEditBlock();

    if (!checked)
    {
        QTextBlockFormat obfmt = cursor.blockFormat();
        QTextBlockFormat bfmt;
        bfmt.setIndent(obfmt.indent());
        cursor.setBlockFormat(bfmt);
    }
    else
    {
        QTextListFormat listFmt;

        if (cursor.currentList())
        {
            listFmt = cursor.currentList()->format();
        }
        listFmt.setStyle(style);
        cursor.createList(listFmt);
    }

    cursor.endEditBlock();
}
开发者ID:Iownnoname,项目名称:qt,代码行数:26,代码来源:mrichtextedit.cpp

示例3: textList

void KNoteEdit::textList()
{
    QTextCursor c = textCursor();
    c.beginEditBlock();

    if ( m_textList->isChecked() ) {
        QTextListFormat lf;
        QTextBlockFormat bf = c.blockFormat();

        lf.setIndent( bf.indent() + 1 );
        bf.setIndent( 0 );

        lf.setStyle( QTextListFormat::ListDisc );

        c.setBlockFormat( bf );
        c.createList( lf );
    } else {
        QTextBlockFormat bf;
        bf.setObjectIndex( -1 );
        c.setBlockFormat( bf );

    }

    c.endEditBlock();
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:25,代码来源:knoteedit.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: cursorPositionChangedSlot

void TextZone::cursorPositionChangedSlot()
{
    if (QApplication::mouseButtons() == Qt::NoButton) {
        centerCursor();
    }


    emit cursorPositionChanged(this->textCursor().position());



    // for textstyle :
    QTextCursor tCursor = this->textCursor();

    if((tCursor.atStart() == true
        || tCursor.position() == 1
        || tCursor.position() == 0) && tCursor.hasSelection() == false){
        this->changeTextStyleSlot(textStyles->defaultStyleIndex());
    }

    int currentStyleIndex = textStyles->compareStylesWithText(tCursor.charFormat(), tCursor.blockFormat());

    emit setStyleSelectionSignal(currentStyleIndex);


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

示例6: updateTextPosition

void GpxBlock::updateTextPosition()
{
	QPointF pos;
  	//_name_item.setTextWidth(_name_item.boundingRect().width());
    QTextCursor cursor = _name_item.textCursor();
  	QTextBlockFormat bfmt = cursor.blockFormat();
 	bfmt.setAlignment(Qt::AlignCenter);
  	cursor.setBlockFormat(bfmt);
  	_name_item.setTextCursor(cursor); 
  	_name_item.setTextWidth(_width+20);

  switch (direction())
  {
    case Graphic::RIGHT:
      pos.setX(-(_name_item.boundingRect().width()/2));
      pos.setY(_height / 2 + 3);
      break;
    case Graphic::LEFT:
      pos.setX((_name_item.boundingRect().width() / 2));
      pos.setY(-_height / 2 - 3);
      break;
    case Graphic::DOWN:
      pos.setY((_name_item.boundingRect().width() / 2));
      pos.setX(_width/ 2 + 3);
      break;
    case Graphic::UP:
      pos.setY(-(_name_item.boundingRect().width() / 2));
      pos.setX(-_width / 2 - 3);
      break;
  }
	_name_item.setPos(pos);
}
开发者ID:lucciano,项目名称:powerdevs,代码行数:32,代码来源:gpx_block.cpp

示例7: 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

示例8: textCursor

void
FormText::alignRight()
{
	QTextCursor c = textCursor();
	QTextBlockFormat b = c.blockFormat();
	b.setAlignment( Qt::AlignRight );
	c.setBlockFormat( b );
	setTextCursor( c );
}
开发者ID:igormironchik,项目名称:prototyper,代码行数:9,代码来源:form_text.cpp

示例9: toggleRightAlign

void TextEditor::toggleRightAlign(bool val)
      {
      QTextCursor cursor = edit->textCursor();
      QTextBlockFormat f = cursor.blockFormat();
      f.setAlignment(val ? Qt::AlignRight : Qt::AlignLeft);
      cursor.setBlockFormat(f);
      edit->setTextCursor(cursor);
      if (val) {
            leftAlign->setChecked(false);
            centerAlign->setChecked(false);
            // rightAlign->setChecked(false);
            }
      }
开发者ID:Angeldude,项目名称:MuseScore,代码行数:13,代码来源:texteditor.cpp

示例10: _insertText

void DisplayText::_insertText(const QString text, const QString bg)
{
    QString tt = text.mid(0,_maxDisplayedCharacters); //truncate to max display chars
    QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
                bg + "\"><pre>" + tt + "</pre></td></tr></table>";

    QTextCursor cursor = textCursor();
    cursor.movePosition(QTextCursor::End);
    QTextBlockFormat bf = cursor.blockFormat();
    bf.setBackground(QBrush(QColor(bg)));
    cursor.insertHtml(s);
    this->setTextCursor(cursor);
}
开发者ID:BackupTheBerlios,项目名称:wsjt-svn,代码行数:13,代码来源:displaytext.cpp

示例11: textDirection

void XYZTextEditor::textDirection() {
    QTextCursor cursor = m_ui->textEdit->textCursor();
    QTextBlockFormat blockFmt = cursor.blockFormat();

    QTextOption topt = m_ui->textEdit->document()->defaultTextOption();
    if (m_ui->btnTextDirection->isChecked()) {
        topt.setTextDirection(Qt::RightToLeft);
        blockFmt.setLayoutDirection(Qt::RightToLeft);
    } else {
        topt.setTextDirection(Qt::LeftToRight);
        blockFmt.setLayoutDirection(Qt::LeftToRight);
    }
    m_ui->textEdit->document()->setDefaultTextOption(topt);
    cursor.setBlockFormat(blockFmt);
}
开发者ID:gamalielmendez,项目名称:BibliotecaImpresionSql,代码行数:15,代码来源:XYZ_TextEditor.cpp

示例12: indent

void MRichTextEdit::indent(int delta)
{
    QTextCursor cursor = f_textedit->textCursor();
    cursor.beginEditBlock();
    QTextBlockFormat bfmt = cursor.blockFormat();
    int ind = bfmt.indent();

    if (ind + delta >= 0)
    {
        bfmt.setIndent(ind + delta);
    }

    cursor.setBlockFormat(bfmt);
    cursor.endEditBlock();
}
开发者ID:Iownnoname,项目名称:qt,代码行数:15,代码来源:mrichtextedit.cpp

示例13: cursorPositionChanged

void TextEditor::cursorPositionChanged()
      {
      QTextCursor cursor = edit->textCursor();
      QTextBlockFormat f = cursor.blockFormat();
      if (f.alignment() & Qt::AlignLeft) {
            leftAlign->setChecked(true);
            centerAlign->setChecked(false);
            rightAlign->setChecked(false);
            }
      else if (f.alignment() & Qt::AlignHCenter) {
            leftAlign->setChecked(false);
            centerAlign->setChecked(true);
            rightAlign->setChecked(false);
            }
      else if (f.alignment() & Qt::AlignRight) {
            leftAlign->setChecked(false);
            centerAlign->setChecked(false);
            rightAlign->setChecked(true);
            }
      }
开发者ID:Angeldude,项目名称:MuseScore,代码行数:20,代码来源:texteditor.cpp

示例14: updateTools

void TextTools::updateTools()
      {
      blockAllSignals(true);
      QTextCursor* cursor = _textElement->cursor();

      QTextCharFormat format = cursor->charFormat();
      QTextBlockFormat bformat = cursor->blockFormat();

      QFont f(format.font());
      typefaceFamily->setCurrentFont(f);
      double ps = f.pointSizeF();
      if (ps == -1.0)
            ps = f.pixelSize() * PPI / MScore::DPI;
      typefaceSize->setValue(ps);
      typefaceItalic->setChecked(format.fontItalic());
      typefaceBold->setChecked(format.fontWeight() == QFont::Bold);
      typefaceUnderline->setChecked(format.fontUnderline());
      typefaceSubscript->setChecked(format.verticalAlignment() == QTextCharFormat::AlignSubScript);
      typefaceSuperscript->setChecked(format.verticalAlignment() == QTextCharFormat::AlignSuperScript);

      centerAlign->setChecked(bformat.alignment() & Qt::AlignHCenter);
      leftAlign->setChecked  (bformat.alignment() & Qt::AlignLeft);
      rightAlign->setChecked (bformat.alignment() & Qt::AlignRight);
      Align align = _textElement->align();
      if (align & ALIGN_BOTTOM) {
            topAlign->setChecked(false);
            bottomAlign->setChecked(true);
            vcenterAlign->setChecked(false);
            }
      else if (align & ALIGN_VCENTER) {
            topAlign->setChecked(false);
            bottomAlign->setChecked(false);
            vcenterAlign->setChecked(true);
            }
      else {
            topAlign->setChecked(true);
            bottomAlign->setChecked(false);
            vcenterAlign->setChecked(false);
            }
      blockAllSignals(false);
      }
开发者ID:briff,项目名称:MuseScore,代码行数:41,代码来源:texttools.cpp

示例15: toggleList

void MainWindow::toggleList(QTextListFormat::Style style)
{
	QTextCursor cursor = ui->textNote->textCursor();
	QTextBlockFormat blockFmt = cursor.blockFormat();
	QTextListFormat listFmt;

	bool list = (cursor.currentList() != 0);

	// change style if list exists and is a different style
	if(list && cursor.currentList()->format().style() != style)
	{
		listFmt.setStyle(style);
		cursor.currentList()->setFormat(listFmt);
	}
	// remove list if exists and matches style
	else if(list&& cursor.currentList()->format().style() == style)
	{
		cursor.currentList()->removeItem(0);
		blockFmt = ui->textNote->textCursor().blockFormat();
		cursor = ui->textNote->textCursor();
		blockFmt.setIndent(0);
		cursor.setBlockFormat(blockFmt);
	// create list if not exists
	}
	else
	{
		cursor.beginEditBlock();
		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();
	}
	updateMenus();
}
开发者ID:itinerant,项目名称:Brainstorm-qt,代码行数:41,代码来源:mainwindow.cpp


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