本文整理汇总了C++中QTextCharFormat::boolProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCharFormat::boolProperty方法的具体用法?C++ QTextCharFormat::boolProperty怎么用?C++ QTextCharFormat::boolProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCharFormat
的用法示例。
在下文中一共展示了QTextCharFormat::boolProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toggleCode
void CreateBlogMsg::toggleCode()
{
static QString preFontFamily;
QTextCharFormat charFormat = ui.msgEdit->currentCharFormat();
QTextCharFormat f;
if ( charFormat.hasProperty( TextFormat::HasCodeStyle ) &&
charFormat.boolProperty( TextFormat::HasCodeStyle ) ) {
f.setProperty( TextFormat::HasCodeStyle, QVariant( false ) );
f.setBackground( defaultCharFormat.background() );
f.setFontFamily( preFontFamily );
ui.msgEdit->textCursor().mergeCharFormat( f );
} else {
preFontFamily = ui.msgEdit->fontFamily();
f.setProperty( TextFormat::HasCodeStyle, QVariant( true ) );
f.setBackground( codeBackground );
f.setFontFamily( "Dejavu Sans Mono" );
ui.msgEdit->textCursor().mergeCharFormat( f );
}
ui.msgEdit->setFocus( Qt::OtherFocusReason );
}
示例2: styleTag
QList<HtmlExporter::tag> HtmlExporter::emitCharFormatStyle( const QTextCharFormat
&charFormat, const QTextBlockFormat &blockFormat )
{
// kDebug() << "html" << html;
QList<HtmlExporter::tag> tags;
bool attributesEmitted = false;
QLatin1String styleTag( "<span style=\"" );
const QString family = charFormat.fontFamily();
//if (!family.isEmpty() && family != defaultCharFormat.fontFamily()) {
// NOTE the above line replaced with the bottom line to use default charFormat, which can be set from outside.
if ( charFormat.hasProperty( BilboTextFormat::HasCodeStyle ) &&
charFormat.boolProperty( BilboTextFormat::HasCodeStyle ) ) {
tags << code;
} else if ( !family.isEmpty() && family != mDefaultCharFormat.fontFamily() ) {
// if ( family.right( 7 ) == "courier" ) {
// tags << code;
// } else {
if ( ! attributesEmitted ) {
html += styleTag;
}
html += QLatin1String( " font-family:'" );
html += family;
html += QLatin1String( "';" );
attributesEmitted = true;
// }
}
// if (format.hasProperty(QTextFormat::FontPointSize)
// && format.fontPointSize() != defaultCharFormat.fontPointSize()) {
// NOTE the above line replaced with the bottom line to use default charFormat, which can be set from outside.
if ( charFormat.hasProperty( QTextFormat::FontPointSize )
&& charFormat.fontPointSize() != mDefaultCharFormat.fontPointSize() ) {
if ( ! attributesEmitted ) {
html += styleTag;
}
html += QLatin1String( " font-size:" );
html += QString::number( charFormat.fontPointSize() );
html += QLatin1String( "pt;" );
attributesEmitted = true;
} else if ( charFormat.hasProperty( QTextFormat::FontSizeAdjustment ) &&
!( blockFormat.hasProperty( BilboTextFormat::HtmlHeading ) &&
blockFormat.intProperty( BilboTextFormat::HtmlHeading ) ) ) {
///To use <h1-5> tags for font size
// const int idx = format.intProperty(QTextFormat::FontSizeAdjustment) + 1;
//
// switch (idx) {
// case 0: tags << h5; break;
// //case 1: tags << h4; break; //NOTE h4 will be the normal text!
// case 2: tags << h3; break;
// case 3: tags << h2; break;
// case 4: tags << h1; break;
// }
///To use <span> tags for font size
static const char * const sizeNames[] = {
"small", "medium", "large", "x-large", "xx-large"
};
const char *name = 0;
const int idx = charFormat.intProperty( QTextFormat::FontSizeAdjustment ) + 1;
if ( idx == 1 ) {
// assume default to not bloat the html too much
} else if ( idx >= 0 && idx <= 4 ) {
name = sizeNames[idx];
}
if ( name ) {
if ( ! attributesEmitted ) {
html += styleTag;
}
html += QLatin1String( " font-size:" );
html += QLatin1String( name );
html += QLatin1Char( ';' );
attributesEmitted = true;
}
}
// if (format.fontWeight() > defaultCharFormat.fontWeight()) {
// NOTE the above line replaced with the bottom line to use default charFormat, which can be set from outside.
if ( charFormat.fontWeight() > mDefaultCharFormat.fontWeight() &&
!( blockFormat.hasProperty( BilboTextFormat::HtmlHeading ) &&
blockFormat.intProperty( BilboTextFormat::HtmlHeading ) ) ) {
tags << strong;
/*if (! attributesEmitted ) html += styleTag;
html += QLatin1String(" font-weight:");
html += QString::number(format.fontWeight() * 8);
html += QLatin1Char(';');
attributesEmitted = true;*/
}
// if (format.fontItalic() != defaultCharFormat.fontItalic()) {
// NOTE the above line replaced with the bottom line to use default charFormat, which can be set from outside.
if ( charFormat.fontItalic() != mDefaultCharFormat.fontItalic() ) {
tags << em;
/*
//.........这里部分代码省略.........