двойные кавычки в расширении параметров Zsh

Как указано в документации:

void QTextEdit::setAlignment(Qt::Alignment a) [slot]

Устанавливает выравнивание текущего абзаца на a. Допустимые выравнивания: Qt::AlignLeft, Qt::AlignRight, Qt::AlignJustify и Qt::AlignCenter (которые расположены по горизонтали).

Ссылка: http://qt-project.org/doc/qt- 5 / qtextedit.html # setAlignment

Итак, как вы можете видеть, вы должны обеспечить некоторое выравнивание каждого абзаца.

Маленький пример:

QTextCursor cursor = ui->textEdit->textCursor();
QTextBlockFormat textBlockFormat = cursor.blockFormat();
textBlockFormat.setAlignment(Qt::AlignRight);//or another alignment
cursor.mergeBlockFormat(textBlockFormat);
ui->textEdit->setTextCursor(cursor);

Какой результат я получаю на своем компьютере?

enter image description here [/g1]

Или что-то ближе к вашему вопросу:

ui->textEdit->clear();
ui->textEdit->append("example");
ui->textEdit->append("example");
QTextCursor cursor = ui->textEdit->textCursor();
QTextBlockFormat textBlockFormat = cursor.blockFormat();
textBlockFormat.setAlignment(Qt::AlignRight);
cursor.mergeBlockFormat(textBlockFormat);
ui->textEdit->setTextCursor(cursor);

ui->textEdit->append("example");

cursor = ui->textEdit->textCursor();
textBlockFormat = cursor.blockFormat();
textBlockFormat.setAlignment(Qt::AlignCenter);
cursor.mergeBlockFormat(textBlockFormat);
ui->textEdit->setTextCursor(cursor);

Результат:

enter image description here [/g2]

0
задан Liu Sha 31 December 2018 в 03:34
поделиться