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


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

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


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

示例1: fillInLinks

void KoPointedAt::fillInLinks(const QTextCursor &cursor, KoInlineTextObjectManager *inlineManager, KoTextRangeManager *rangeManager)
{
    bookmark = 0;
    externalHRef.clear();
    note = 0;

    if (!inlineManager)
        return;

    // Is there an href here ?
    if (cursor.charFormat().isAnchor()) {
        QString href = cursor.charFormat().anchorHref();
        // local href starts with #
        if (href.startsWith("#")) {
            // however bookmark does not contain it, so strip it
            href = href.right(href.size() - 1);

            if (!href.isEmpty()) {
                bookmark = rangeManager->bookmarkManager()->bookmark(href);
            }
            return;
        } else {
            // Nope, then it must be external;
            externalHRef = href;
        }
    } else {
        note = dynamic_cast<KoInlineNote*>(inlineManager->inlineTextObject(cursor));
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:29,代码来源:KoPointedAt.cpp

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

示例3: textEditToPlainText

QString ChatEdit::textEditToPlainText()
{
	QTextDocument *doc = document();
	QString result;
	result.reserve(doc->characterCount());
	QTextCursor begin(doc);
	QTextCursor end;
	QString specialChar = QChar(QChar::ObjectReplacementCharacter);
	bool first = true;
	while (!begin.atEnd()) {
		end = doc->find(specialChar, begin, QTextDocument::FindCaseSensitively);
		QString postValue;
		bool atEnd = end.isNull();
		if (atEnd) {
			end = QTextCursor(doc);
			QTextBlock block = doc->lastBlock();
			end.setPosition(block.position() + block.length() - 1);
		} else {
			postValue = end.charFormat().toolTip();
		}
		begin.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
						   end.position() - begin.position() - (atEnd ? 0 : 1));
		QString selectionText = begin.selection().toPlainText();
		if (!first)
			result += selectionText.midRef(1);
		else
			result += selectionText;
		result += postValue;
		begin = end;
		end.clearSelection();
		first = false;
	}
	return result;
}
开发者ID:akahan,项目名称:qutim,代码行数:34,代码来源:chatedit.cpp

示例4: textCursor

void
FormText::clearFormat()
{
	QTextCursor c = textCursor();

	if( c.hasSelection() )
	{
		QTextCharFormat fmt = c.charFormat();

		fmt.setFontUnderline( false );
		fmt.setFontItalic( false );
		fmt.setFontWeight( QFont::Normal );
		fmt.setFontPointSize( 10 );

		textCursor().setCharFormat( fmt );
	}
	else
	{
		QFont f = font();
		f.setUnderline( false );
		f.setItalic( false );
		f.setWeight( QFont::Normal );
		f.setPointSize( 10.0 );

		setFont( f );
	}

	QRectF r = boundingRect();
	r.moveTo( pos() );

	d->m_proxy->setRect( r );
}
开发者ID:igormironchik,项目名称:prototyper,代码行数:32,代码来源:form_text.cpp

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

示例6: edit

            text_writer( docEdit& e ) : edit( e ) {
                QTextCursor cursor = edit.textCursor();
                cursor.movePosition( QTextCursor::Start );
                mainFrame = cursor.currentFrame();

                plainFormat = cursor.charFormat();
                plainFormat.setFontPointSize( 10 );

                paragraphFormat = plainFormat;
                paragraphFormat.setFontPointSize( 12 );

                headingFormat = plainFormat;
                headingFormat.setFontWeight( QFont::Bold );
                headingFormat.setFontPointSize( 16 );

                empasisFormat = plainFormat;
                empasisFormat.setFontItalic( true );

                tagFormat = plainFormat;
                tagFormat.setForeground( QColor( "#990000" ) );
                tagFormat.setFontUnderline( true );
                
                underlineFormat = plainFormat;
                underlineFormat.setFontUnderline( true );

                frameFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Inset );
                frameFormat.setBorder( 1 );
                frameFormat.setMargin( 10 );
                frameFormat.setPadding( 4 );
            }
开发者ID:hermixy,项目名称:qtplatz,代码行数:30,代码来源:docedit.cpp

示例7: toggleItalicText

void ItemEditorWidget::toggleItalicText()
{
    QTextCursor tc = textCursor();
    QTextCharFormat format = tc.charFormat();
    format.setFontItalic( !format.fontItalic() );
    tc.setCharFormat(format);
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:7,代码来源:itemeditorwidget.cpp

示例8: formatError

QT_BEGIN_NAMESPACE

static void formatError(const QFormScriptRunner::Error &error,
                        QTextCursor &cursor)
{
    const QTextCharFormat oldFormat = cursor.charFormat();
    // Message
    cursor.insertText(QCoreApplication::translate("ScriptErrorDialog", "An error occurred while running the scripts for \"%1\":\n").arg(error.objectName));

    QTextCharFormat format(oldFormat);

    // verbatim listing
    format.setFontFamily(QLatin1String("Courier"));
    cursor.insertText(error.script, format);

    const QString newLine(QLatin1Char('\n'));

    cursor.insertText(newLine);

    // red error
    format = oldFormat;
    format.setTextOutline(QPen(Qt::red));
    cursor.insertText(error.errorMessage, format);
    cursor.insertText(newLine);
    cursor.setCharFormat (oldFormat);
}
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:26,代码来源:scripterrordialog.cpp

示例9: caretOwner

QString CaretInterface::caretOwner(const QTextCursor& cursor)
{
    QTextCharFormat fmt = cursor.charFormat();
    if ( fmt.objectType() == CaretFormat )
        return fmt.property(Owner).toString();
    return QString::null;
}
开发者ID:Narsil,项目名称:QWave,代码行数:7,代码来源:caret.cpp

示例10: appendMessageToCurrentSession

/*! Append a new message to the current session and scroll to the end of the message protocol and
    returns true if the action was successful. The \a messageColor defines the color of the message
    box and should be provided as a full-color (no dimming required) color, as it is automatically
    adjusted for the border and background.
*/
bool QwcPrivateMessager::appendMessageToCurrentSession(QTextDocument *document, const QString message, const QColor messageColor)
{
    if (!document) { return false; }

    QTextCursor cursor = document->rootFrame()->lastCursorPosition();
    cursor.movePosition(QTextCursor::StartOfBlock);

    QTextFrameFormat frameFormat;
    frameFormat.setPadding(4);
    frameFormat.setBackground(messageColor.lighter(190));
    frameFormat.setMargin(0);
    frameFormat.setBorder(2);
    frameFormat.setBorderBrush(messageColor.lighter(150));
    frameFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Outset);

    // Title
    QTextCharFormat backupCharFormat = cursor.charFormat();

    QTextCharFormat newCharFormat;
    newCharFormat.setFontPointSize(9);

    QTextBlockFormat headerFormat;
    headerFormat.setAlignment(Qt::AlignHCenter);
    cursor.insertBlock(headerFormat);
    cursor.setCharFormat(newCharFormat);
    cursor.insertText(QDateTime::currentDateTime().toString());

    QTextFrame *frame = cursor.insertFrame(frameFormat);
    cursor.setCharFormat(backupCharFormat);
    frame->firstCursorPosition().insertText(message);

    return true;
}
开发者ID:pcjpnet,项目名称:qwired-suite,代码行数:38,代码来源:QwcPrivateMessager.cpp

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

示例12: toggleUnderlineText

void ItemEditorWidget::toggleUnderlineText()
{
    QTextCursor tc = textCursor();
    QTextCharFormat format = tc.charFormat();
    format.setFontUnderline( !format.fontUnderline() );
    tc.setCharFormat(format);
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:7,代码来源:itemeditorwidget.cpp

示例13: toggleStrikethroughText

void ItemEditorWidget::toggleStrikethroughText()
{
    QTextCursor tc = textCursor();
    QTextCharFormat format = tc.charFormat();
    format.setFontStrikeOut( !format.fontStrikeOut() );
    tc.setCharFormat(format);
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:7,代码来源:itemeditorwidget.cpp

示例14: fontFamily

QString DocumentHandler::fontFamily() const
{
    QTextCursor cursor = textCursor();
    if (cursor.isNull())
        return QString();
    QTextCharFormat format = cursor.charFormat();
    return format.font().family();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:8,代码来源:documenthandler.cpp

示例15: textColor

QColor DocumentHandler::textColor() const
{
    QTextCursor cursor = textCursor();
    if (cursor.isNull())
        return QColor(Qt::black);
    QTextCharFormat format = cursor.charFormat();
    return format.foreground().color();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:8,代码来源:documenthandler.cpp


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