2 Star 12 Fork 0

rewine / DMarked

 / 详情

本地图片不显示

已完成
创建于  
2021-12-07 10:50

输入图片说明

评论 (8)

sonichy 创建了任务
rewine 添加了
 
feature
标签

目前情况是,我是打开qrc里的html文件,显示本地图片时,会寻找qrc://, 而不是files://,即使我配置了

 this->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true);
 this->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);

也不管用,但导出html,用浏览器查看是有图片的

rewine 添加了
 
bug
标签
rewine 移除了
 
feature
标签

@sonichy 发现你挺熟悉Qt,这个有什么解决方法吗?求助

你的太复杂,编译有错误([Makefile:41:sub-qmarkdowntextedit-qmake_all] 错误 2),无法调试。
转化为绝对路径了吗?
https://gitee.com/sonichy/HTYMD/blob/master/mainwindow.cpp#L346

if (!url.contains("://")) url = QFileInfo(path).absolutePath() + "/" + url;

输入图片说明

我测试用的就是绝对路径,并且导出的html用其他浏览器打开是有图片的,只有 qtwebengine 下不显示

看上去是第三方的 qmarkdowntextedit 编译失败了,具体报错是什么?

只有这一条
[Makefile:41:sub-qmarkdowntextedit-qmake_all] 错误 2

默认会渲染成 img src="/home/rewine/a.jpg" alt="avatar",因为html是qrc打开的,不显示图片

改成 img src="file:///home/rewine/a.jpg" alt="avatar" 即可显示

https://github.com/DMarked/DMarked/commit/8d2e91c176d4750203546cf2256115bc4dc50728

rewine 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
5254539 rewine 1578983299 634095 sonichy 1580833826
C++
1
https://gitee.com/rewine/DMarked.git
git@gitee.com:rewine/DMarked.git
rewine
DMarked
DMarked

搜索帮助

53164aa7 5694891 3bd8fe86 5694891