Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

评论区富文本展示问题 #6

Open
goplayegg opened this issue Aug 30, 2020 · 3 comments
Open

评论区富文本展示问题 #6

goplayegg opened this issue Aug 30, 2020 · 3 comments

Comments

@goplayegg
Copy link
Owner

Qt富文本原生不支持gif动图,只能显示第一帧,评论区如果要显示gif用AnimatedImage 会cpu很高,排版效果很差

@goplayegg
Copy link
Owner Author

  • 评论富文本方案
  • 1.先用TextArea,gif默认不能播放,给图片加上链接可以点击,点击后弹出窗口进行gif播放
  • 2.看源码修改TextEdit的c++类实现富文本gif Qt5.12.3\5.12.3\Src\qtdeclarative\src\quick\items\qquicktextedit.cpp
  • 3.改用QWebEngine网页渲染评论区,这样文章也能使用Web,缺点软件体积大,运行时占用一个浏览器资源。 会成为桌面大型应用的后续趋势?

@goplayegg
Copy link
Owner Author

方案1 先用TextArea,gif默认不能播放,给图片加上链接可以点击,点击后弹出窗口进行gif播放
相关问题楼层

@goplayegg
Copy link
Owner Author

方案1 先用TextArea,gif默认不能播放,给图片加上链接可以点击,点击后弹出窗口进行gif播放
相关问题楼层

使用qml的TextArea 展示html时发现网络图片会在第一次显示不出来,必须双击或改变窗口大小才显示出来,又或者相同的图片url第二次插入到TextArea里也能在首次显示出来。
在Repeater/ListView之类的用model的容器里放TextArea才有这个问题,可能是Qt的bug

    Repeater {
       id: repCmt
       model: 5
       delegate: TextArea {
           width: parent
           textFormat: Qt.RichText
           persistentSelection: true
           selectByMouse: true
           readOnly: true
           wrapMode: TextArea.Wrap
           text:"<img src=\"https://static.yximgs.com/bs2/adminBlock/treasure-1598137811221-SKJNDStR.png\">"
       }
   }

这个问题的2个方案:

  • TextArea 里的网络图片img都先自己下载好转成base64, 用<img src="data:image/png;base64,aaaaaaaaa>这种可能得以解决
  • 网图和其他文本分开展示,目前评论的网图跟其他文本正好都是独立开,在评论的最后的, 用一个Column显示吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant