Qt-QTextEdit文字排版


1. 設置段落對齊

textEdit->setAlignment(Qt::AlignLeft);  //左對齊
textEdit->setAlignment(Qt::AlignRight);  //右對齊
textEdit->setAlignment(Qt::AlignCenter);  //居中
textEdit->setAlignment(Qt::AlignJustify);  //兩端對齊

2. 設置文本對齊

    用於描述文本排序格式的QTextListFormat包含兩個基本的屬性:QTextListFormat::style,表示文本采用哪種排序方式;QTextListFormat::indent,表示排序后的縮進值

QTextCursor textCursor = textEdit->textCursor();  //獲得編輯框中的光標
QTextListFormat::Style style = QTextListFormat::ListDisc;  //黑色實心圓點
textCursor.beginEditBlock();
QTextListFormat listFormat;
listFormat.setIndent(2);
listFormat.setStyle(style);
textCursor.createList(listFormat);
textCursor.endEditBlock();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM