QTextEdit 插入Html 表格(table)
来源:互联网 发布:mac上的杀毒软件 编辑:程序博客网 时间:2024/05/22 00:25
业务需求:想要实现下图效果:
然而直接使用html代码:
<table style="width: 124px; height: 88px;" border="1"> <tbody> <tr> <td style="background-color: rgb(255, 255, 102);">A</td> <td>1</td> </tr> <tr> <td style="background-color: rgb(51, 204, 255); width: 126.8px;">B</td> <td style="width: 411.2px;">2</td> </tr> <tr> <td style="background-color: rgb(153, 51, 153);">C</td> <td>3</td> </tr> </tbody> </table>
在QTextEdit中却没有效果,主要是没有边框。
经过搜索,找到QTextTable可以在QTextEdit中插入表格,QTextList用于插入列表。
更多内容可参考帮助:Rich Text Processing
具体实现:(忽略颜色)
QTextCursor cursor(this->ui->_textEdit->textCursor()); cursor.movePosition(QTextCursor::Start); QTextTable _table=cursor.insertTable(3,2); _table.cellAt(0,0).firstCursorPosition().insertHtml("A"); _table.cellAt(0,1).firstCursorPosition().insertHtml("1"); _table.cellAt(1,0).firstCursorPosition().insertHtml("B"); _table.cellAt(1,1).firstCursorPosition().insertHtml("2"); _table.cellAt(2,0).firstCursorPosition().insertHtml("C"); _table.cellAt(2,1).firstCursorPosition().insertHtml("3");
另外要说的是,表格的分割和合并。
比如要把上图中数字2的位置分割成三行,想通过splitCell直接分割是不能实现的。
能做的只能是先插入一个5行2列的表格,然后把中间三个的第一个单元格合并。
阅读全文
0 0
- QTextEdit 插入Html 表格(table)
- html生成表格table
- html 表格table
- html table表格标签
- html 不规则table表格
- html --table表格
- HTML 表格table
- HTML-表格(TABLE)标记(TAGS)
- HTML-表格进阶(TABLE ADVANCED)
- Html 表单表格 form table
- html+css学习----表格table
- html table(2)表格标签
- 【html 表格样式】table 设置
- 插入HTML标签或表格
- HTML--表格(TABLE)标记(TAGS)
- HTML--表格进阶(TABLE ADVANCED)
- 收藏! 表格(table) 高级的使用方法 (html)
- html表格(table)样式说明
- 面试题24:二叉树的后序遍历序列
- Git 基本命令整理
- linux ls 命令
- 推荐一款免费的C#界面库
- oracle update select ,从A中select后写入B
- QTextEdit 插入Html 表格(table)
- 泛型<?super T> 和<? extends T>区别
- iOS银联网页支付出现的界面没有适配手机端的解决办法!
- 只有年月的输入框
- 二叉树操作
- Spring IOC三种注入方式(接口注入、setter注入、构造器注入)
- Android EditText 文本内容超过文本框失去焦点后,超出文本框内容显示...
- android驱动USB摄像头了
- AI/机器学习/深度学习三者的区别是什么?