本文整理汇总了C++中TextEdit::addSyntaxHighlighter方法的典型用法代码示例。如果您正苦于以下问题:C++ TextEdit::addSyntaxHighlighter方法的具体用法?C++ TextEdit::addSyntaxHighlighter怎么用?C++ TextEdit::addSyntaxHighlighter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEdit
的用法示例。
在下文中一共展示了TextEdit::addSyntaxHighlighter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sanityCheck
void tst_SyntaxHighlighter::sanityCheck()
{
delete new Highlighter; // make sure null parent doesn't crash
{
TextEdit edit;
SyntaxHighlighter *s = new Highlighter(&edit);
QVERIFY(s->textEdit() == &edit);
QCOMPARE(edit.syntaxHighlighters().size(), 1);
QVERIFY(edit.syntaxHighlighters().first() == s);
QVERIFY(edit.syntaxHighlighter() == s);
delete s;
QCOMPARE(edit.syntaxHighlighters().size(), 0);
}
{
QPointer<SyntaxHighlighter> ptr;
TextEdit *textEdit = new TextEdit;
ptr = new Highlighter(textEdit);
delete textEdit;
QVERIFY(!ptr);
}
{
QPointer<SyntaxHighlighter> ptr;
TextEdit *textEdit = new TextEdit;
ptr = new Highlighter;
textEdit->addSyntaxHighlighter(ptr);
delete textEdit;
QVERIFY(ptr);
delete ptr;
}
{
TextEdit edit;
QPointer<SyntaxHighlighter> s = new Highlighter;
edit.setSyntaxHighlighter(s);
QCOMPARE(edit.syntaxHighlighters().size(), 1);
QVERIFY(edit.syntaxHighlighters().first() == s);
QVERIFY(edit.syntaxHighlighter() == s);
edit.setSyntaxHighlighter(s);
QCOMPARE(edit.syntaxHighlighters().size(), 1);
QVERIFY(edit.syntaxHighlighters().first() == s);
QVERIFY(edit.syntaxHighlighter() == s);
SyntaxHighlighter *s2 = new Highlighter;
edit.setSyntaxHighlighter(s2);
QCOMPARE(edit.syntaxHighlighters().size(), 1);
QVERIFY(edit.syntaxHighlighters().first() == s2);
QVERIFY(edit.syntaxHighlighter() == s2);
QVERIFY(!s->textEdit());
}
{
TextEdit edit;
QList<SyntaxHighlighter*> list;
for (int i=0; i<1024; ++i) {
list.append(new Highlighter(&edit));
}
QCOMPARE(list, edit.syntaxHighlighters());
}
{
TextEdit edit;
Highlighter hl;
hl.setTextEdit(&edit);
}
}