QML Image内部缓存导致的问题

QML Image BUG

BUG描述:两个界面login.qml 和 modify.qml 页面,内部代码大致如下:

Camera{
    id: camera

    imageProcessing {
        whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
    }

    exposure {
        exposureCompensation: -1.0
        exposureMode: Camera.ExposurePortrait
    }

    flash.mode: Camera.FlashRedEyeReduction

    imageCapture {

        onImageCaptured: {
            console.info("image captured", preview)
            // image://camera/preview_<requestid>
            displayImg.source = preview
        }

        onImageSaved: {
            //imageStore(path);
        }
    }
}

VideoOutput{
    id: voutput
    anchors.fill: parent
    source: camera
    fillMode:VideoOutput.PreserveAspectCrop
}

Image{
    id: displayImg
    visible: false
    anchors.fill: parent
    cache: false;  // 解决的地方
}

两个界面的主体部分都是获取camera中的图像,并显示到Image中.

BUG: login中的最后capture的图像会时不时的出现在modify的Image中。

解决思路:去掉内部缓存。

依据:qt帮助 -> Image -> Performace中的一句话

Images are cached and shared internally, so if several Image items have the same source, only one copy of the image will be loaded.

就是内部共享,同源时只有一个被加载,就是说,两个页面的preview的URL相同时,其中都有可能被加载到Image中,这里的处理方式是直接把cache:false,因为项目中摄像头图片都是实时的不需要你缓存。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值