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