本文整理汇总了C++中QTextCursor::createList方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCursor::createList方法的具体用法?C++ QTextCursor::createList怎么用?C++ QTextCursor::createList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCursor
的用法示例。
在下文中一共展示了QTextCursor::createList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: textList
void KNoteEdit::textList()
{
QTextCursor c = textCursor();
c.beginEditBlock();
if ( m_textList->isChecked() ) {
QTextListFormat lf;
QTextBlockFormat bf = c.blockFormat();
lf.setIndent( bf.indent() + 1 );
bf.setIndent( 0 );
lf.setStyle( QTextListFormat::ListDisc );
c.setBlockFormat( bf );
c.createList( lf );
} else {
QTextBlockFormat bf;
bf.setObjectIndex( -1 );
c.setBlockFormat( bf );
}
c.endEditBlock();
}
示例2: textStyle
void GraphicTextDialog::textStyle(int styleIndex)
{
QTextCursor cursor = textEdit->textCursor();
if(styleIndex != 0) {
QTextListFormat::Style style = QTextListFormat::ListDisc;
switch (styleIndex) {
default:
case 1:
style = QTextListFormat::ListDisc;
break;
case 2:
style = QTextListFormat::ListCircle;
break;
case 3:
style = QTextListFormat::ListSquare;
break;
case 4:
style = QTextListFormat::ListDecimal;
break;
case 5:
style = QTextListFormat::ListLowerAlpha;
break;
case 6:
style = QTextListFormat::ListUpperAlpha;
break;
}
cursor.beginEditBlock();
QTextBlockFormat blockFmt = cursor.blockFormat();
QTextListFormat listFmt;
if(cursor.currentList()) {
listFmt = cursor.currentList()->format();
} else {
listFmt.setIndent(blockFmt.indent() + 1);
blockFmt.setIndent(0);
cursor.setBlockFormat(blockFmt);
}
listFmt.setStyle(style);
cursor.createList(listFmt);
cursor.endEditBlock();
} else {
// ####
QTextBlockFormat bfmt;
bfmt.setObjectIndex(-1);
cursor.mergeBlockFormat(bfmt);
}
}
示例3: list
void MRichTextEdit::list(bool checked, QTextListFormat::Style style)
{
QTextCursor cursor = f_textedit->textCursor();
cursor.beginEditBlock();
if (!checked)
{
QTextBlockFormat obfmt = cursor.blockFormat();
QTextBlockFormat bfmt;
bfmt.setIndent(obfmt.indent());
cursor.setBlockFormat(bfmt);
}
else
{
QTextListFormat listFmt;
if (cursor.currentList())
{
listFmt = cursor.currentList()->format();
}
listFmt.setStyle(style);
cursor.createList(listFmt);
}
cursor.endEditBlock();
}
示例4: setStyle
//段落标号、编号
void MyChild::setStyle(int style)
{
QTextCursor cursor = this->textCursor();
if (style != 0) {
QTextListFormat::Style stylename = QTextListFormat::ListDisc;
switch (style) {
default:
case 1:
stylename = QTextListFormat::ListDisc;
break;
case 2:
stylename = QTextListFormat::ListCircle;
break;
case 3:
stylename = QTextListFormat::ListSquare;
break;
case 4:
stylename = QTextListFormat::ListDecimal;
break;
case 5:
stylename = QTextListFormat::ListLowerAlpha;
break;
case 6:
stylename = QTextListFormat::ListUpperAlpha;
break;
case 7:
stylename = QTextListFormat::ListLowerRoman;
break;
case 8:
stylename = QTextListFormat::ListUpperRoman;
break;
}
cursor.beginEditBlock();
QTextBlockFormat blockFmt = cursor.blockFormat();
QTextListFormat listFmt;
if (cursor.currentList()) {
listFmt = cursor.currentList()->format();
} else {
listFmt.setIndent(blockFmt.indent() + 1);
blockFmt.setIndent(0);
cursor.setBlockFormat(blockFmt);
}
listFmt.setStyle(stylename);
cursor.createList(listFmt);
cursor.endEditBlock();
} else {
QTextBlockFormat bfmt;
bfmt.setObjectIndex(-1);
cursor.mergeBlockFormat(bfmt);
}
}
示例5: setList
/*!
* \brief Changes the list attribute of the selected text to \a v
*/
void QwwRichTextEdit::setList(bool v){
QTextCursor cur = textCursor();
if(v){
QTextListFormat listFormat;
listFormat.setStyle(QTextListFormat::ListDisc);
currentList = cur.createList(listFormat);
} else {
cur.setBlockFormat(QTextBlockFormat());
// cur.movePosition(QTextCursor::NextBlock);
// cur.insertBlock(QTextBlockFormat());
setTextCursor(cur);
currentList = 0;
}
}
示例6: event
/*!
* \internal
*/
bool QwwRichTextEdit::event(QEvent *e){
if(e->type()!=QEvent::KeyPress)
return QTextEdit::event(e);
QKeyEvent *ke = (QKeyEvent*)e;
currentList = textCursor().currentList();
if(currentList){
if(ke->key()==Qt::Key_Tab || ke->key() ==Qt::Key_Backtab){
QTextCursor cur = textCursor();
QTextListFormat listFormat = currentList->format();
listFormat.setIndent(currentList->format().indent()+ (ke->key()== Qt::Key_Tab ? 1 : -1));
// listFormat.setStyle(QTextListFormat::ListDisc);
currentList = cur.createList(listFormat);
return true;
}
}
return QTextEdit::event(e);
}
示例7: toggleList
void MainWindow::toggleList(QTextListFormat::Style style)
{
QTextCursor cursor = ui->textNote->textCursor();
QTextBlockFormat blockFmt = cursor.blockFormat();
QTextListFormat listFmt;
bool list = (cursor.currentList() != 0);
// change style if list exists and is a different style
if(list && cursor.currentList()->format().style() != style)
{
listFmt.setStyle(style);
cursor.currentList()->setFormat(listFmt);
}
// remove list if exists and matches style
else if(list&& cursor.currentList()->format().style() == style)
{
cursor.currentList()->removeItem(0);
blockFmt = ui->textNote->textCursor().blockFormat();
cursor = ui->textNote->textCursor();
blockFmt.setIndent(0);
cursor.setBlockFormat(blockFmt);
// create list if not exists
}
else
{
cursor.beginEditBlock();
if (cursor.currentList()) {
listFmt = cursor.currentList()->format();
} else {
listFmt.setIndent(blockFmt.indent() + 1);
blockFmt.setIndent(0);
cursor.setBlockFormat(blockFmt);
}
listFmt.setStyle(style);
cursor.createList(listFmt);
cursor.endEditBlock();
}
updateMenus();
}
示例8: sl_ListButton_Toggled
void TextEditWidget::sl_ListButton_Toggled(bool toggle) {
QTextCursor cursor = this->textField->textCursor();
if (toggle) {
if (cursor.currentList()) {
WARNING("Wrong button state");
return;
}
QTextListFormat format;
format.setStyle(QTextListFormat::ListDisc);
cursor.createList(format);
} else {
QTextList *textList = cursor.currentList();
if (!cursor.currentList()) {
WARNING("Wrong button state");
return;
}
QTextBlock block = cursor.block();
textList->remove(block);
QTextBlockFormat format = block.blockFormat();
format.setIndent(0);
cursor.setBlockFormat(format);
}
}