本文整理汇总了C++中QTextCharFormat::colorProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCharFormat::colorProperty方法的具体用法?C++ QTextCharFormat::colorProperty怎么用?C++ QTextCharFormat::colorProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCharFormat
的用法示例。
在下文中一共展示了QTextCharFormat::colorProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testUnapplyStyle
void TestStyles::testUnapplyStyle()
{
// Used to test OverlineColor style
QColor testOverlineColor(255, 128, 64);
KoCharacterStyle::LineWeight testOverlineWeight = KoCharacterStyle::ThickLineWeight;
qreal testOverlineWidth = 1.5;
// in this test we should avoid testing any of the hardcodedDefaultProperties; see KoCharacterStyle for details!
KoParagraphStyle headers;
headers.setOverlineColor(testOverlineColor);
headers.setOverlineMode(KoCharacterStyle::ContinuousLineMode);
headers.setOverlineStyle(KoCharacterStyle::DottedLine);
headers.setOverlineType(KoCharacterStyle::DoubleLine);
headers.setOverlineWidth(testOverlineWeight, testOverlineWidth);
headers.setFontWeight(QFont::Bold);
headers.setAlignment(Qt::AlignCenter);
KoParagraphStyle head1;
head1.setParentStyle(&headers);
head1.setLeftMargin(QTextLength(QTextLength::FixedLength, 40));
QTextDocument doc;
doc.setPlainText("abc");
QTextBlock block = doc.begin();
head1.applyStyle(block);
QTextCursor cursor(block);
QTextBlockFormat bf = cursor.blockFormat();
KoParagraphStyle bfStyle (bf, cursor.charFormat());
QCOMPARE(bf.alignment(), Qt::AlignCenter);
QCOMPARE(bfStyle.leftMargin(), 40.);
QTextCharFormat cf = cursor.charFormat();
QCOMPARE(cf.colorProperty(KoCharacterStyle::OverlineColor), testOverlineColor);
QCOMPARE(cf.intProperty(KoCharacterStyle::OverlineMode), (int) KoCharacterStyle::ContinuousLineMode);
QCOMPARE(cf.intProperty(KoCharacterStyle::OverlineStyle), (int) KoCharacterStyle::DottedLine);
QCOMPARE(cf.intProperty(KoCharacterStyle::OverlineType), (int) KoCharacterStyle::DoubleLine);
QCOMPARE(cf.intProperty(KoCharacterStyle::OverlineWeight), (int) testOverlineWeight);
QCOMPARE(cf.doubleProperty(KoCharacterStyle::OverlineWidth), testOverlineWidth);
head1.unapplyStyle(block);
bf = cursor.blockFormat();
QCOMPARE(bf.hasProperty(QTextFormat::BlockAlignment), false);
QCOMPARE(bf.hasProperty(QTextFormat::BlockLeftMargin), false);
cf = cursor.charFormat();
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineColor), false);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineMode), false);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineStyle), false);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineType), false);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineWeight), false);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineWidth), false);
doc.clear();
block = doc.begin();
head1.applyStyle(block);
bf = cursor.blockFormat();
KoParagraphStyle bfStyle2 (bf, cursor.charFormat());
QCOMPARE(bf.alignment(), Qt::AlignCenter);
QCOMPARE(bfStyle2.leftMargin(), 40.);
cf = cursor.charFormat();
//QCOMPARE(cf.fontOverline(), true);
QCOMPARE(cf.colorProperty(KoCharacterStyle::OverlineColor), testOverlineColor);
QCOMPARE(cf.intProperty(KoCharacterStyle::OverlineMode), (int) KoCharacterStyle::ContinuousLineMode);
QCOMPARE(cf.intProperty(KoCharacterStyle::OverlineStyle), (int) KoCharacterStyle::DottedLine);
QCOMPARE(cf.intProperty(KoCharacterStyle::OverlineType), (int) KoCharacterStyle::DoubleLine);
QCOMPARE(cf.intProperty(KoCharacterStyle::OverlineWeight), (int) testOverlineWeight);
QCOMPARE(cf.doubleProperty(KoCharacterStyle::OverlineWidth), testOverlineWidth);
head1.unapplyStyle(block);
bf = cursor.blockFormat();
QCOMPARE(bf.hasProperty(QTextFormat::BlockAlignment), false);
QCOMPARE(bf.hasProperty(QTextFormat::BlockLeftMargin), false);
cf = cursor.charFormat();
//QCOMPARE(cf.hasProperty(QTextFormat::FontOverline), false);
doc.setHtml("bla bla<i>italic</i>enzo");
block = doc.begin();
head1.applyStyle(block);
bf = cursor.blockFormat();
KoParagraphStyle bfStyle3(bf, cursor.charFormat());
QCOMPARE(bf.alignment(), Qt::AlignCenter);
QCOMPARE(bfStyle3.leftMargin(), 40.);
cf = cursor.charFormat();
//QCOMPARE(cf.fontOverline(), true);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineColor), true);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineMode), true);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineStyle), true);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineType), true);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineWeight), true);
QCOMPARE(cf.hasProperty(KoCharacterStyle::OverlineWidth), true);
cursor.setPosition(7);
cursor.setPosition(12, QTextCursor::KeepAnchor);
QTextCharFormat italic;
italic.setFontItalic(true);
cursor.mergeCharFormat(italic);
cursor.setPosition(8);
cf = cursor.charFormat();
QCOMPARE(cf.fontItalic(), true);
cursor.setPosition(0);
//.........这里部分代码省略.........