QTextEdit 取消选中
QTextEdit 在设置字体颜色和大小时需调用selectAll()函数,但没有取消选中接口,解决方法如下:
//保存状态再恢复
QTextCursor cursor = textEdit->textCursor();
textEdit->selectAll();
textEdit->setFontPointSize(18);
textEdit->setTextCursor(cursor);
//移动光标到文档末尾
textEdit->selectAll();
textEdit->setFontPointSize(18);
QTextCursor cursor = textEdit->textCursor();
cursor.movePosition(QTextCursor::End);
textEdit->setTextCursor(cursor);