本文整理汇总了C++中QTextCharFormat::clearForeground方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCharFormat::clearForeground方法的具体用法?C++ QTextCharFormat::clearForeground怎么用?C++ QTextCharFormat::clearForeground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCharFormat
的用法示例。
在下文中一共展示了QTextCharFormat::clearForeground方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toggleDescriptionEditMode
void FormattedTextWidget::toggleDescriptionEditMode( bool isFormattedTextMode )
{
d->m_formattedTextToolBar->setVisible( isFormattedTextMode );
d->m_fontSize->setVisible( isFormattedTextMode );
d->m_fontFamily->setVisible( isFormattedTextMode );
if( isFormattedTextMode ) {
d->m_description->setHtml( d->m_description->toPlainText() );
} else {
QTextCursor cursor = d->m_description->textCursor();
QTextCharFormat format;
format.setFont( QFont() );
format.setFontWeight( QFont::Normal );
format.setFontItalic( false );
format.setFontUnderline( false );
format.clearForeground();
cursor.setCharFormat( format );
d->m_description->setTextCursor( cursor );
d->m_description->setPlainText( d->m_description->toHtml() );
}
}
示例2: set_text_color
static void set_text_color(void *_object)
{
QTextCharFormat fmt;
QBrush col;
GB_COLOR fg = CWIDGET_get_foreground((CWIDGET *)THIS);
fmt = WIDGET->currentCharFormat();
if (fg == COLOR_DEFAULT)
{
fmt.clearForeground();
//col = WIDGET->palette().text();
}
else
{
fmt.setForeground(TO_QCOLOR(fg));
}
//WIDGET->setTextColor(col);
THIS->no_change = TRUE;
WIDGET->setCurrentCharFormat(fmt);
THIS->no_change = FALSE;
}
示例3: insertFromMimeData
//.........这里部分代码省略.........
bottMargin = cursor.blockFormat().bottomMargin();
textIndent = cursor.blockFormat().textIndent();
leftMargin = cursor.blockFormat().leftMargin();
textAlignment = cursor.blockFormat().alignment();
textHeight = cursor.charFormat().fontPointSize();
fontFamily = cursor.charFormat().fontFamily();
}
if(source->hasHtml() && !forceCopyWithoutFormatting){
QByteArray richtext;
if (source->hasFormat(QLatin1String("text/rtf"))) {
richtext = source->data(QLatin1String("text/rtf"));
} else if (source->hasHtml()) {
richtext = mimeToRtf(source);
}
QTextEdit *textEdit = new QTextEdit(0);
RTF::Reader reader;
QBuffer buffer(&richtext);
buffer.open(QIODevice::ReadOnly);
reader.read(&buffer, textEdit->textCursor());
buffer.close();
QString sourceString = textEdit->toHtml();
sourceString.remove(QChar::ReplacementCharacter);
sourceString.remove(QChar::ObjectReplacementCharacter);
sourceString.remove(QChar::Null);
//htmlText
QTextDocument *document = new QTextDocument;
document->setHtml(Utils::parseHtmlText(sourceString));
QTextBlockFormat blockFormat;
blockFormat.setBottomMargin(bottMargin);
blockFormat.setTextIndent(textIndent);
blockFormat.setLeftMargin(leftMargin);
blockFormat.setAlignment(textAlignment);
blockFormat.setRightMargin(0);
QTextCharFormat charFormat;
charFormat.setFontPointSize(textHeight);
charFormat.setFontFamily(fontFamily);
charFormat.setBackground(QBrush(Qt::NoBrush));
charFormat.setForeground(QBrush(Qt::NoBrush));
charFormat.setAnchor(false);
charFormat.setUnderlineStyle(QTextCharFormat::NoUnderline);
charFormat.setFontStrikeOut(false);
QTextCursor *tCursor = new QTextCursor(document);
tCursor->movePosition(QTextCursor::Start, QTextCursor::MoveAnchor,1);
tCursor->movePosition(QTextCursor::End, QTextCursor::KeepAnchor,1);
tCursor->mergeCharFormat(charFormat);
tCursor->mergeBlockFormat(blockFormat);
QTextCursor cursor = this->textCursor();
cursor.insertHtml(document->toHtml("utf-8"));
qDebug() << "insertFromMimeData Html";
}
else if(source->hasText() || forceCopyWithoutFormatting){
QTextDocument *document = new QTextDocument;
document->setPlainText(qvariant_cast<QString>(source->text()));
QTextBlockFormat blockFormat;
blockFormat.setBottomMargin(bottMargin);
blockFormat.setTextIndent(textIndent);
blockFormat.setLeftMargin(leftMargin);
blockFormat.setAlignment(textAlignment);
blockFormat.setRightMargin(0);
QTextCharFormat charFormat;
charFormat.setFontPointSize(textHeight);
charFormat.setFontFamily(fontFamily);
charFormat.clearForeground();
charFormat.setBackground(QBrush(Qt::NoBrush));
charFormat.setForeground(QBrush(Qt::NoBrush));
charFormat.setAnchor(false);
charFormat.setUnderlineStyle(QTextCharFormat::NoUnderline);
charFormat.setFontStrikeOut(false);
QTextCursor *tCursor = new QTextCursor(document);
tCursor->movePosition(QTextCursor::Start, QTextCursor::MoveAnchor,1);
tCursor->movePosition(QTextCursor::End, QTextCursor::KeepAnchor,1);
tCursor->mergeCharFormat(charFormat);
tCursor->mergeBlockFormat(blockFormat);
QTextCursor cursor = this->textCursor();
cursor.insertHtml(document->toHtml("utf-8"));
qDebug() << "insertFromMimeData plainText";
}
}