QML Image: Invalid image provider with modified declarative camera example
-
I'm updating our application to Qt6.2.
We have a CameraQml widget, which is based on the declarative camera example and has the ability to save the captured image. The images are being saved OK but the preview window only displays the first captured photo. For subsequent photos the preview window shows a black screen and there is the error message:
qrc:/resources/camera_qml/PhotoPreview.qml:59:5: QML Image: Invalid image provider: image://camera/preview_1This is on Ubuntu 20.04, though I don't think this is a platform-related issue.
The declarative camera example runs fine and does not display this message so I'm pretty sure the problem is in my code. It seems like something isn't getting tidied up properly.
I've extracted the relevant code into an example at https://github.com/martinburchell/qml-camera-example .
The main application is at:
https://github.com/martinburchell/qml-camera-example/blob/main/main.cppThe widget containing the QML is at:
https://github.com/martinburchell/qml-camera-example/blob/main/cameraqml.cppThe QML is different from the example in the following ways:
https://github.com/martinburchell/qml-camera-example/blob/main/resources/camera_qml/camera.qml
We've added:
- handlers for
onImageCapturedandonImageSavedtoImageCapture. - a custom handler for
onImageSavedToFiletoPhotoPreview - a custom
fileNoLongerNeededsignal to tidy up saved images
The
CameraButtononClickedhandler sends thefileNoLongerNeededsignal mentioned above.https://github.com/martinburchell/qml-camera-example/blob/main/resources/camera_qml/PhotoPreview.qml
We've added a Save button, which sends the
imageSavedToFilesignal.Any suggestions as to what the problem might be?
- handlers for
-
I'm updating our application to Qt6.2.
We have a CameraQml widget, which is based on the declarative camera example and has the ability to save the captured image. The images are being saved OK but the preview window only displays the first captured photo. For subsequent photos the preview window shows a black screen and there is the error message:
qrc:/resources/camera_qml/PhotoPreview.qml:59:5: QML Image: Invalid image provider: image://camera/preview_1This is on Ubuntu 20.04, though I don't think this is a platform-related issue.
The declarative camera example runs fine and does not display this message so I'm pretty sure the problem is in my code. It seems like something isn't getting tidied up properly.
I've extracted the relevant code into an example at https://github.com/martinburchell/qml-camera-example .
The main application is at:
https://github.com/martinburchell/qml-camera-example/blob/main/main.cppThe widget containing the QML is at:
https://github.com/martinburchell/qml-camera-example/blob/main/cameraqml.cppThe QML is different from the example in the following ways:
https://github.com/martinburchell/qml-camera-example/blob/main/resources/camera_qml/camera.qml
We've added:
- handlers for
onImageCapturedandonImageSavedtoImageCapture. - a custom handler for
onImageSavedToFiletoPhotoPreview - a custom
fileNoLongerNeededsignal to tidy up saved images
The
CameraButtononClickedhandler sends thefileNoLongerNeededsignal mentioned above.https://github.com/martinburchell/qml-camera-example/blob/main/resources/camera_qml/PhotoPreview.qml
We've added a Save button, which sends the
imageSavedToFilesignal.Any suggestions as to what the problem might be?
- handlers for