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,因为项目中摄像头图片都是实时的不需要你缓存。