本文整理汇总了C++中QTextCursor::currentList方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCursor::currentList方法的具体用法?C++ QTextCursor::currentList怎么用?C++ QTextCursor::currentList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCursor
的用法示例。
在下文中一共展示了QTextCursor::currentList方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例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: highlightListItems
void MainWindow::highlightListItems()
{
QTextCursor cursor = editor->textCursor();
QTextList *list = cursor.currentList();
if (!list)
return;
cursor.beginEditBlock();
//! [0]
for (int index = 0; index < list->count(); ++index) {
QTextBlock listItem = list->item(index);
//! [0]
QTextBlockFormat newBlockFormat = listItem.blockFormat();
newBlockFormat.setBackground(Qt::lightGray);
QTextCursor itemCursor = cursor;
itemCursor.setPosition(listItem.position());
//itemCursor.movePosition(QTextCursor::StartOfBlock);
itemCursor.movePosition(QTextCursor::EndOfBlock,
QTextCursor::KeepAnchor);
itemCursor.setBlockFormat(newBlockFormat);
/*
//! [1]
processListItem(listItem);
//! [1]
*/
//! [2]
}
//! [2]
cursor.endEditBlock();
}
示例5: sl_IncreaseListIndent_Triggered
void TextEditWidget::sl_IncreaseListIndent_Triggered() {
QTextCursor cursor = this->textField->textCursor();
QTextList *textList = cursor.currentList();
if (!textList) {return;}
QTextListFormat format = textList->format();
format.setIndent(format.indent() + 1);
textList->setFormat(format);
}
示例6: 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);
}
}
示例7: sl_TextEdit_CursorPositionChanged
void TextEditWidget::sl_TextEdit_CursorPositionChanged() {
ACTBold->setChecked(textField->fontWeight() == QFont::Bold);
ACTItalic->setChecked(textField->fontItalic());
ACTUnderline->setChecked(textField->fontUnderline());
strikeOutAction->setChecked(textField->StrikedOut());
ACTAlignLeft->setChecked(textField->GetAlignment() == Qt::AlignLeft);
ACTAlignCenter->setChecked(textField->GetAlignment() == Qt::AlignHCenter);
ACTAlignRight->setChecked(textField->GetAlignment() == Qt::AlignRight);
alignJustifyAction->setChecked(textField->GetAlignment() == Qt::AlignJustify);
listButton->blockSignals(true);
const QTextCursor cursor = textField->textCursor();
const QTextList *textList = cursor.currentList();
listButton->setChecked(textList != 0);
increaseListIndentAction->setVisible(textList != 0);
decreaseListIndentAction->setVisible(textList != 0);
listButton->blockSignals(false);
fontComboBox->blockSignals(true);
const QFont temp = textField->currentFont();
fontComboBox->setCurrentFont(temp);
fontComboBox->blockSignals(false);
fontSizeComboBox->blockSignals(true);
const int size = this->textField->currentFont().pointSize();
const int index = fontSizeComboBox->findData(size);
if (index != -1) {
fontSizeComboBox->setCurrentIndex(index);
}
fontSizeComboBox->blockSignals(false);
const QTextTable* table = textField->textCursor().currentTable();
const bool tablePresent = (table != 0);
insertRowAction->setEnabled(tablePresent);
insertColumnAction->setEnabled(tablePresent);
removeRowAction->setEnabled(tablePresent);
removeColumnAction->setEnabled(tablePresent);
mergeCellsAction->setEnabled(tablePresent);
tablePropertiesAction->setEnabled(tablePresent);
if (tablePresent) {
createTableAction->setText("Edit table...");
} else {
createTableAction->setText("Create table");
}
}
示例8: 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();
}
示例9: sl_ListButton_Triggered
void TextEditWidget::sl_ListButton_Triggered(QAction* action) {
if (!action) {
WARNING("Null pointer recieved");
return;
}
QTextListFormat::Style style = (QTextListFormat::Style)action->data().toInt();
QTextCursor cursor = this->textField->textCursor();
QTextList *textList = cursor.currentList();
if (!textList) {
WARNING("Wrong button state");
return;
}
QTextListFormat format = textList->format();
format.setStyle(style);
textList->setFormat(format);
}
示例10: 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();
}
示例11: 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();
}