本文整理汇总了C++中QTextCursor::insertList方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCursor::insertList方法的具体用法?C++ QTextCursor::insertList怎么用?C++ QTextCursor::insertList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCursor
的用法示例。
在下文中一共展示了QTextCursor::insertList方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exp
QTextList *tryReadList(QTextList *list, const QString &line)
{
QTextList *listOut = list;
QRegularExpression exp("^( *)(\\d+\\.|\\*) (.*)$");
QRegularExpressionMatch match = exp.match(line);
if (match.hasMatch())
{
const int indent = match.captured(1).size() / 2 + 1;
const QString contents = match.captured(3);
const bool ordered = match.captured(2) != "*";
QTextListFormat fmt;
fmt.setStyle(ordered ? QTextListFormat::ListDecimal : QTextListFormat::ListDisc);
fmt.setIndent(indent);
if (!listOut || fmt != listOut->format())
{
listOut = cursor.insertList(fmt);
}
else
{
cursor.insertBlock();
}
readInlineText(contents);
listOut->add(cursor.block());
return listOut;
}
else
{
return 0;
}
}
示例2: insertList
void MainWindow::insertList()
{
QTextCursor cursor = editor->textCursor();
cursor.beginEditBlock();
QTextList *list = cursor.currentList();
QTextListFormat listFormat;
if (list)
listFormat = list->format();
listFormat.setStyle(QTextListFormat::ListDisc);
listFormat.setIndent(listFormat.indent() + 1);
cursor.insertList(listFormat);
cursor.endEditBlock();
}
示例3: insertList
void MainWindow::insertList()
{
QTextCursor cursor = editor->textCursor();
cursor.beginEditBlock();
//! [add a styled, ordered list]
QTextListFormat listFormat;
listFormat.setStyle(QTextListFormat::ListDecimal);
listFormat.setNumberPrefix("(");
listFormat.setNumberSuffix(")");
cursor.insertList(listFormat);
//! [add a styled, ordered list]
cursor.endEditBlock();
}
示例4: insertList
void MainWindow::insertList()
{
QTextCursor cursor = editor->textCursor();
cursor.beginEditBlock();
QTextList *list = cursor.currentList();
//! [0]
listFormat = QTextListFormat()
if list:
listFormat = list.format()
listFormat.setIndent(listFormat.indent() + 1)
listFormat.setStyle(QTextListFormat.ListDisc)
cursor.insertList(listFormat)
//! [0]
cursor.endEditBlock();
}
示例5: on_insetList_clicked
void MainWindow::on_insetList_clicked()
{
QInputDialog dlg;
QStringList items;
items << tr("○..., ○..., ○...")
<< tr("●..., ●..., ●...")
<< tr("■..., ■..., ■...")
<< tr("1..., 2..., 3...")
<< tr("a..., b..., c...")
<< tr("A..., B..., C...")
<< tr("i..., ii..., iii...")
<< tr("I..., II..., III...");
bool ok;
QString item = QInputDialog::getItem(this, tr("请选择列表样式"),
tr("列表前缀:"), items, 0, false, &ok);
if (!ok || item.isEmpty())
return;
QTextEdit *pEdit = textEditor.editor;
QTextCursor cursor = pEdit->textCursor();
QTextListFormat listFormat;
if(item == tr("○..., ○..., ○..."))
listFormat.setStyle(QTextListFormat::ListCircle);
else if(item == tr("●..., ●..., ●..."))
listFormat.setStyle(QTextListFormat::ListDisc);
else if(item == tr("■..., ■..., ■..."))
listFormat.setStyle(QTextListFormat::ListSquare);
else if(item == tr("1..., 2..., 3..."))
listFormat.setStyle(QTextListFormat::ListDecimal);
else if(item == tr("a..., b..., c..."))
listFormat.setStyle(QTextListFormat::ListLowerAlpha);
else if(item == tr("A..., B..., C..."))
listFormat.setStyle(QTextListFormat::ListUpperAlpha);
else if(item == tr("i..., ii..., iii..."))
listFormat.setStyle(QTextListFormat::ListLowerRoman);
else
listFormat.setStyle(QTextListFormat::ListUpperRoman);
cursor.insertList(listFormat);
pEdit->setFocus();
}
示例6: read
//.........这里部分代码省略.........
}
}
else if (token.type == Token::Italic)
{
fmt.setFontItalic(!fmt.fontItalic());
}
else if (token.type == Token::InlineCodeDelimiter)
{
while (iterator.hasNext())
{
const Token next = iterator.next();
if (next.type == Token::InlineCodeDelimiter)
{
break;
}
else
{
cursor.insertText(token.source, codeFmt);
}
}
}
else if (token.type == Token::Character)
{
cursor.insertText(token.content.toChar(), fmt);
}
else
{
cursor.insertText(token.source, fmt);
}
}
}
};
if (paralist.second.indent == -1)
{
const Paragraph paragraph = paralist.first;
QTextCharFormat charFmt;
QTextBlockFormat blockFmt;
blockFmt.setBottomMargin(5.0f);
if (Paragraph::FirstHeading <= paragraph.type && paragraph.type <= Paragraph::LastHeading)
{
charFmt.setFontPointSize(sizeMap[paragraph.type]);
}
else if (paragraph.type == Paragraph::Quote)
{
blockFmt.setIndent(1);
}
else if (paragraph.type == Paragraph::Code)
{
blockFmt.setNonBreakableLines(true);
charFmt.setFontFamily("Monospace");
}
if (!firstBlock)
{
cursor.insertBlock();
}
else
{
firstBlock = false;
}
cursor.setBlockFormat(blockFmt);
cursor.block().setUserState(paragraph.type);
insertTokens(paragraph.tokens, charFmt, paragraph.type == Paragraph::Code);
}
else
{
const List list = paralist.second;
qDebug() << "##########################" << list.indent << list.ordered;
std::for_each(list.paragraphs.begin(), list.paragraphs.end(), [](const Paragraph &item){qDebug() << item;});
cursor.setBlockFormat(QTextBlockFormat());
cursor.setBlockCharFormat(QTextCharFormat());
QTextListFormat listFormat;
listFormat.setStyle(list.ordered ? QTextListFormat::ListDecimal : QTextListFormat::ListDisc);
listFormat.setIndent(list.indent);
QTextList *l = cursor.insertList(listFormat);
qDebug() << "inserting list" << list.indent;
bool firstBlock = true;
for (const Paragraph ¶graph : list.paragraphs)
{
if (firstBlock)
{
firstBlock = false;
}
else
{
cursor.insertBlock();
qDebug() << "inserting block";
}
insertTokens(paragraph.tokens, QTextCharFormat(), false);
qDebug() << l->count();
l->add(cursor.block());
qDebug() << l->count();
qDebug() << "inserting characters";
}
}
}
cursor.endEditBlock();
qDebug() << doc->toHtml();
}
示例7: parseFrame
void Format::parseFrame( QTextCursor &cursor, const QDomElement &element )
{
QTextBlock extraBlock;
bool hasExtraBlock = false;
QDomNode n;
for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
QDomElement e = n.toElement();
if ( e.tagName() == "block" ) {
if ( e.hasAttribute( "liststyle" ) ) {
cursor.setCharFormat( TextFormats::normalCharFormat() );
QTextListFormat f;
f.setIndent( e.attribute( "listindent" ).toInt() );
if ( e.attribute( "liststyle" ) == "decimal" ) {
f.setStyle( QTextListFormat::ListDecimal );
} else {
f.setStyle( QTextListFormat::ListDisc );
}
cursor.mergeBlockFormat( TextFormats::normalBlockFormat() );
cursor.insertList( f );
} else if ( n != element.firstChild() ) {
QTextBlockFormat f;
if ( e.hasAttribute( "blockindent" ) ) {
f.setIndent( e.attribute( "blockindent" ).toInt() );
} else {
f.setIndent( 0 );
}
if ( hasExtraBlock ) {
QTextCursor c( extraBlock );
c.setBlockFormat( f );
hasExtraBlock = false;
} else {
cursor.insertBlock( f );
}
}
if ( e.hasAttribute( "lastmodified" ) ) {
QString str = e.attribute( "lastmodified" );
QDateTime dt = QDateTime::fromString( str, Qt::ISODate );
TextFormats::setLastModified( cursor, dt );
}
parseBlock( cursor, e );
if ( e.hasAttribute( "titlestyle" ) ) {
if ( e.attribute( "titlestyle" ) == "title" ) {
cursor.mergeBlockFormat( TextFormats::titleBlockFormat() );
} else if ( e.attribute( "titlestyle" ) == "subtitle" ) {
cursor.mergeBlockFormat( TextFormats::subTitleBlockFormat() );
}
} else {
cursor.mergeBlockFormat( TextFormats::normalBlockFormat() );
}
} else if ( e.tagName() == "frame" ) {
QTextFrame *parentFrame = cursor.currentFrame();
QTextFrame *frame = cursor.insertFrame( TextFormats::codeFrameFormat() );
parseFrame( cursor, e );
if ( e.attribute( "type" ) == "code" ) {
TextFormats::setCodeFrameFormats( frame );
}
cursor = parentFrame->lastCursorPosition();
extraBlock = cursor.block();
hasExtraBlock = true;
}
}
}