QtQuick中解析富文本<初>
2016-07-05 22:26
645 查看
#include<QTextFragment> void TQmlHelper::makeDoc( QQuickTextDocument* doc) { jAVA_QMessage("开始"); QTextDocument *document =doc->textDocument(); if(document==NULL) { jAVA_QMessage("NULL DOCUMENT"); } QTextBlock currentBlock = document->begin(); QTextBlock::iterator it; while( true) { for (it = currentBlock.begin(); !(it.atEnd()); ) { QTextFragment currentFragment = it.fragment(); QTextImageFormat newImageFormat = currentFragment.charFormat().toImageFormat(); if (newImageFormat.isValid()) { // 为image jAVA_QMessage(newImageFormat.name()); } ++it; } currentBlock = currentBlock.next(); jAVA_QMessage("一循环"); if(!currentBlock.isValid()) { break; } } }
Rectangle{ id:sendroot xxx.. property var offsetBeginX: 20 property var offsetendx: 10 Rectangle{ id: flickable x:offsetBeginX anchors.bottom: parent.bottom width: sendroot.width - btn.width -offsetBeginX-offsetendx height:edit.focus==true?flick.height:btn.height color: "transparent" radius: 5 border.width: 1 border.color: "#cccccc" clip: true Flickable{ id:flick width: parent.width height: contentHeight>100?100:contentHeight contentHeight: edit.height TextArea.flickable: TextArea{ Material.foreground : "#ffffff" id:edit padding: 0 width: parent.width font.pointSize: 14 height: contentHeight>btn.height?contentHeight:btn.height wrapMode: TextArea.Wrap textFormat: TextEdit.RichText text:"Hello~~" Component.onCompleted: { edit.insert(edit.length,"<img width='48' height='48' src='qrc:/image/close_1.png'>"); } onTextChanged: { lizi.dodo(20) } onFocusChanged: { if(focus == true) { cursorPosition = length } } Lizi{ id:lizi x:edit.cursorRectangle.x y:edit.cursorRectangle.y 每秒发射个数:10 初始大小:8 大小变化范围:14 初始生命:1000 生命变化范围:500 粒子速度:20 角度:0 角度变化范围:360 } } ScrollBar.vertical: ScrollBar{ active: true pressed: true} } } Ola.Button{ x:flickable.x+flickable.width + offsetendx anchors.bottom: parent.bottom id:btn text:"发送" isDefault: true // font.bold: true // font.pointSize: 14 height: 40 width: 100 onClicked: { myapp.jAVA_QMessage(edit.textDocument); myapp.makeDoc(edit.textDocument); xxx.. } } }
相关文章推荐
- IOS真机切换UI界面时,出现“Only run on the main thread” 的解决方法
- 在android studio中新建android gradle project的时候connect refused:connect或者卡在building project...或Refreshing
- 225. Implement Stack using Queues
- leetcode 232. Implement Queue using Stacks
- How do I iterate over a Scala List (or more generally, a sequence) using theforeach method or for loop?
- 232. Implement Queue using Stacks
- iOS开发 纯代码创建UICollectionView 听语音
- 【Android UI】ListView的使用和简单优化
- quick3.3模拟器的横屏
- Junit4出现java.lang.NoSuchMethodError: org.junit.runner.Request.classWithoutSuiteMethod
- Leetcode 51. N-Queens
- UITableView代理cellForRowAtIndexPath不执行的相关解决方案
- poj1776Task Sequences【竞赛图的哈密顿路径】
- [UE4教程] 图形学基础教程01--渲染管线 (带演示程序)
- sqlserver -- 解决sqlserver2008“Prevent saving changes that require table re_creation(阻止保存要求重新创建表的更改)”的问题
- 1443. Printer Queue
- UITableViewHeaderFooterView 特点
- 1002.Anti-prime Sequences
- 导入pullloadmorerecyclerview库出现错误:Please configure your build for VectorDrawableCompat
- leetcode 334. Increasing Triplet Subsequence