开发笔记

  • 首页
  • 工具箱
三味线的博客
  1. 首页
  2. Qt
  3. 正文

QTextEdit 取消选中

2019-07-01 1364点热度 5人点赞 0条评论

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);
标签: Qt
最后更新:2020-06-06

三味线

不吃咸鱼的喵

点赞
< 上一篇
下一篇 >

文章评论

取消回复

Captcha Code

COPYRIGHT © 2022 voidcat.cn. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

蜀ICP备18010095号-1