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


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

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


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

示例1: updateCustomTextColor

/*!
	This slot applies custom text color for user - entered text
    It does not affect the text originally inserted into editor
 */
void NmEditorTextEdit::updateCustomTextColor()
{
    NM_FUNCTION;
    
    if (mCustomTextColor.first) {
        QTextCursor tcursor = textCursor();
        QTextCharFormat fmt;
        int pos = tcursor.position();
        if (pos > 0) {
            // If there isn't any user-made selection - apply custom color
            if (!tcursor.hasSelection() && !tcursor.hasComplexSelection()) {
                // Select last added char and set its color to custom
                if (tcursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, 1)
                    && tcursor.hasSelection()) {
                    fmt = tcursor.charFormat();
                    fmt.setForeground(mCustomTextColor.second);
                    tcursor.mergeCharFormat(fmt);
                }
            }
        }
        else {
            fmt = tcursor.charFormat();
            fmt.setForeground(mCustomTextColor.second);
            tcursor.mergeCharFormat(fmt);
            setTextCursor(tcursor);
        }
    }
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:32,代码来源:nmeditortextedit.cpp

示例2: markCurrentLocation

void OCamlSource::markCurrentLocation()
{
    timer_index++;
    if ( _start_char != 0  && _end_char != 0 )
    {
        if ( timer_index < nb_timer_values )
        { // blink
            QTextCharFormat selectedFormat;
            QColor outlineColor;

            if ( timer_index % 2 == 0 )
                outlineColor = QColor( Qt::darkYellow );
            else
                outlineColor = QColor( Qt::yellow );

            selectedFormat.setBackground( outlineColor );
            QTextCursor cur = textCursor();
            cur.movePosition( QTextCursor::Start, QTextCursor::MoveAnchor );
            cur.movePosition( QTextCursor::NextCharacter, QTextCursor::MoveAnchor, _start_char );
            cur.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, _end_char - _start_char );

            cur.mergeCharFormat( selectedFormat );
        }
        else
        {
           
            QColor currentPositionColor = QColor( Qt::darkYellow );
            QColor currentInstructionColor = QColor( Qt::yellow );
            QTextCharFormat currentPositionFormat;
            currentPositionFormat.setBackground( currentPositionColor );
            QTextCharFormat currentInstructionFormat;
            currentInstructionFormat.setBackground( currentInstructionColor );

            QTextCursor cur = textCursor();
            cur.movePosition( QTextCursor::Start, QTextCursor::MoveAnchor );
            cur.movePosition( QTextCursor::NextCharacter, QTextCursor::MoveAnchor, _start_char );
            cur.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, _end_char - _start_char );

            cur.mergeCharFormat( currentInstructionFormat );

            int current_position ;
            if (_after)
                current_position = _end_char - 1;
            else
                current_position = _start_char;

            cur.movePosition( QTextCursor::Start, QTextCursor::MoveAnchor );
            cur.movePosition( QTextCursor::NextCharacter, QTextCursor::MoveAnchor, current_position );
            cur.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor );

            cur.mergeCharFormat( currentPositionFormat );
        }
    }
    if ( timer_index < nb_timer_values )
    {
        markCurrentLocationTimer->setInterval( timer_values[ timer_index % nb_timer_values ] );
        markCurrentLocationTimer->start();
    }
}
开发者ID:modlfo,项目名称:oqamldebug_qt5,代码行数:59,代码来源:ocamlsource.cpp

示例3: attach

void KoTextInlineRdf::attach(KoTextInlineRdf *inlineRdf, QTextCursor &cursor)
{
    QTextCharFormat format = cursor.charFormat();
    QVariant v = QVariant::fromValue(inlineRdf);
    format.setProperty(KoCharacterStyle::InlineRdf, v);
    cursor.mergeCharFormat(format);
}
开发者ID:KDE,项目名称:calligra-history,代码行数:7,代码来源:KoTextInlineRdf.cpp

示例4: iniFontSize

//init font size
void TextEdit::iniFontSize(){
  //the document contains 50 lines
  cout<<"#textedit::inifontsize";
  QString s="12";
  qreal pointSize = s.toFloat();
  QTextCharFormat fmt;
  fmt.setFontPointSize(pointSize);
  //QColor col = Qt::red;
  //fmt.setForeground(col);
  ///textEdit->setCurrentCharFormat(fmt);

  //cursor is the main widget which handle document editing
  QTextCursor cursor = textEdit->textCursor();
  //cursor.setPosition(120,QTextCursor::MoveAnchor);
  //cursor.movePosition(QTextCursor::NoMove,QTextCursor::KeepAnchor,100000);//textEdit->document().length());
  ////mergeFormatOnWordOrSelection(fmt);

  //cursor has four selection type: the last one select the entire document
  cursor.select(QTextCursor::Document);
  cursor.mergeCharFormat(fmt);
  //  QTextBlock block=cursor.block();
  //  cout<<"TextEdit.initFontSize:the block start and length:";
  //  cout<<block.position()<<","<<block.length();
  //  cout<<"TextEdit.initFontSize:the block text:"<<block.text();
  //cursor.setPosition(0);
}
开发者ID:counterstriker,项目名称:qtapplications,代码行数:27,代码来源:textedit.cpp

示例5: setUnderline

/*!
 * \brief   Changes the underline attribute of the selected text to \a v
 */
void QwwRichTextEdit::setUnderline(bool v){
    QTextCursor cur = textCursor();
    QTextCharFormat fmt;
    fmt.setFontUnderline(v);
    cur.mergeCharFormat(fmt);
    setTextCursor(cur);
  }
开发者ID:dewhisna,项目名称:KingJamesPureBibleSearch,代码行数:10,代码来源:qwwrichtextedit.cpp

示例6: setFontColorPer

void Setting::setFontColorPer()
{
    QFont pFont;
    QColor  pColor;

    if(radioButtonProgFC->isChecked())
    {
        pFont =fontprog;
        pColor =Qt::black;
    }
    else  if(radioButtonQuranFC->isChecked())
    {
        pFont =fontchapter;
        pColor =colorQ.currentColor();
    }
    else  if(radioButtonTrFC->isChecked())
    {
        pFont =fontchapterTr;
        pColor =colorTr.currentColor();
    } else if(radioButtonBooksFC)
    {
        pFont =fontBook;
        pColor =colorBook.currentColor();
    }

    QTextCharFormat fmt;
    fmt.setForeground(pColor);
    fmt.setFont(pFont);
    textEditFontPerviwe->selectAll();
    QTextCursor cursor = textEditFontPerviwe->textCursor();
    cursor.mergeCharFormat(fmt);
    textEditFontPerviwe->mergeCurrentCharFormat(fmt);
    cursor.clearSelection();
    textEditFontPerviwe->setTextCursor(cursor);
}
开发者ID:alanvar,项目名称:Al-Anavr,代码行数:35,代码来源:setting.cpp

示例7: textCursor

void
SimpleRichTextEdit::setRichText(const SubtitleComposer::SString &richText)
{
	setPlainText(richText.string());

	QTextCursor cursor = textCursor();
	cursor.setPosition(0);

	int currentStyleFlags = -1;
	QRgb currentStyleColor = 0;
	QTextCharFormat format;
	for(int position = 0, size = richText.length(); position < size; ++position) {
		if(currentStyleFlags != richText.styleFlagsAt(position) || ((richText.styleFlagsAt(position) & SubtitleComposer::SString::Color) && currentStyleColor != richText.styleColorAt(position))) {
			currentStyleFlags = richText.styleFlagsAt(position);
			currentStyleColor = richText.styleColorAt(position);
			format.setFontWeight(currentStyleFlags & SubtitleComposer::SString::Bold ? QFont::Bold : QFont::Normal);
			format.setFontItalic(currentStyleFlags & SubtitleComposer::SString::Italic);
			format.setFontUnderline(currentStyleFlags & SubtitleComposer::SString::Underline);
			format.setFontStrikeOut(currentStyleFlags & SubtitleComposer::SString::StrikeThrough);
			if((currentStyleFlags &SubtitleComposer::SString::Color) == 0)
				format.setForeground(QBrush());
			else
				format.setForeground(QBrush(QColor(currentStyleColor)));
		}

		cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, 1);
		cursor.mergeCharFormat(format);
		cursor.setPosition(position + 1);
	}

	clearUndoRedoHistory();
}
开发者ID:maxrd2,项目名称:subtitlecomposer,代码行数:32,代码来源:simplerichtextedit.cpp

示例8: stopDebugging

QString OCamlSource::stopDebugging( const QString &file, int start_char, int end_char , bool after)
{
    if ( curFile != file )
        loadFile( file );
    QTextCharFormat unselectedFormat;
    unselectedFormat.setBackground( Qt::white );

    QTextCursor cur = textCursor();
    cur.movePosition( QTextCursor::Start, QTextCursor::MoveAnchor );
    cur.movePosition( QTextCursor::End, QTextCursor::KeepAnchor );
    cur.mergeCharFormat( unselectedFormat );

    cur.movePosition( QTextCursor::Start, QTextCursor::MoveAnchor );
    cur.movePosition( QTextCursor::NextCharacter, QTextCursor::MoveAnchor, start_char );

    setTextCursor( cur );

    centerCursor();
    _start_char = start_char;
    _end_char = end_char;
    _after = after;
    timer_index = 0;
    markBreakPoints(false);
    markCurrentLocation();

    cur.movePosition( QTextCursor::Start, QTextCursor::MoveAnchor );
    cur.movePosition( QTextCursor::NextCharacter, QTextCursor::MoveAnchor, _start_char );
    cur.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, _end_char - _start_char );
    QString text = cur.selectedText();

    return text;
}
开发者ID:modlfo,项目名称:oqamldebug_qt5,代码行数:32,代码来源:ocamlsource.cpp

示例9: mergeFormatOnWordOrSelection

void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
{
    QTextCursor cursor = textCursor();
    if (!cursor.hasSelection())
        cursor.select(QTextCursor::WordUnderCursor);
    cursor.mergeCharFormat(format);
}
开发者ID:andy0130tw,项目名称:terrarium-app,代码行数:7,代码来源:documenthandler.cpp

示例10: mergeFormatOnWordOrSelection

void XYZTextEditor::mergeFormatOnWordOrSelection(const QTextCharFormat &format) {
    QTextCursor cursor = m_ui->textEdit->textCursor();
    if (!cursor.hasSelection())
        cursor.select(QTextCursor::WordUnderCursor);
    cursor.mergeCharFormat(format);
    m_ui->textEdit->mergeCurrentCharFormat(format);
}
开发者ID:gamalielmendez,项目名称:BibliotecaImpresionSql,代码行数:7,代码来源:XYZ_TextEditor.cpp

示例11: mergeFormatOnWordOrSelection

void MailEditorMainWindow::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
  {
  QTextCursor cursor = ui->messageEdit->textCursor();
  if(cursor.hasSelection() == false)
    cursor.select(QTextCursor::WordUnderCursor);
  cursor.mergeCharFormat(format);
  ui->messageEdit->mergeCurrentCharFormat(format);
  }
开发者ID:toby82,项目名称:keyhotee,代码行数:8,代码来源:maileditorwindow.cpp

示例12: setTextCursorFont

void FormattedTextWidget::setTextCursorFont( const QFont &font )
{
    QTextCursor cursor = d->m_description->textCursor();
    QTextCharFormat format;
    format.setFontFamily( font.family() );
    cursor.mergeCharFormat( format );
    d->m_description->setTextCursor( cursor );
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:8,代码来源:FormattedTextWidget.cpp

示例13: setTextCursorUnderlined

void FormattedTextWidget::setTextCursorUnderlined( bool underlined )
{
    QTextCursor cursor = d->m_description->textCursor();
    QTextCharFormat format;
    format.setFontUnderline( underlined );
    cursor.mergeCharFormat( format );
    d->m_description->setTextCursor( cursor );
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:8,代码来源:FormattedTextWidget.cpp

示例14: setTextCursorItalic

void FormattedTextWidget::setTextCursorItalic( bool italic )
{
    QTextCursor cursor = d->m_description->textCursor();
    QTextCharFormat format;
    format.setFontItalic( italic );
    cursor.mergeCharFormat( format );
    d->m_description->setTextCursor( cursor );
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:8,代码来源:FormattedTextWidget.cpp

示例15: setTextCursorBold

void FormattedTextWidget::setTextCursorBold( bool bold )
{
    QTextCursor cursor = d->m_description->textCursor();
    QTextCharFormat format;
    format.setFontWeight( bold ? QFont::Bold : QFont::Normal );
    cursor.mergeCharFormat( format );
    d->m_description->setTextCursor( cursor );
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:8,代码来源:FormattedTextWidget.cpp


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