找回密码
 立即注册
收起左侧

Image source 怎样设置如果对于资源不存在则使用默认资源

2
回复
5717
查看
[复制链接]
累计签到:12 天
连续签到:1 天
来源: 2016-7-2 21:32:36 显示全部楼层 |阅读模式
1Qter豆
QtQuick control ,我想做一个图片控件,如果不指定source,就使用默认的图片(类似于占位图),如果指定了source,但是source不存在的话也使用默认的占位图,如果source是网络文件,在无法获取网络资源时也显示默认占位图,求教该怎么办?

基本结构:
  1. MyImage{
  2.     id: myImage
  3.     property alias source:image.source
  4.    
  5.     Image{
  6.         id:image
  7.         source:"qrc:///img/default.png"
  8.     }
  9. }
复制代码

最佳答案

查看完整内容

status : enumeration This property holds the status of image loading. It can be one of: Image.Null - no image has been set Image.Ready - the image has been loaded Image.Loading - the image is currently being loaded Image.Error - an error occurred while loading the image 多看看文档就有解决办法了
回复

使用道具 举报

尚未签到

2016-7-2 21:32:37 显示全部楼层
status : enumeration
This property holds the status of image loading. It can be one of:

Image.Null - no image has been set
Image.Ready - the image has been loaded
Image.Loading - the image is currently being loaded
Image.Error - an error occurred while loading the image


多看看文档就有解决办法了
回复

使用道具 举报

累计签到:12 天
连续签到:1 天
2016-7-3 08:25:24 显示全部楼层
Joey_Chan 发表于 2016-7-2 22:27
status : enumeration
This property holds the status of image loading. It can be one of:

感谢,确实是没仔细看文档,英文水平还不够,经常看落下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了