Details
-
Bug
-
Resolution: Fixed
-
P4: Low
-
6.2.4
-
None
Description
I'm not sure if this is a bug or if I'm doing something wrong here. There's definitely inconsistent behaviour on Ubuntu and MacOS.
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_1
This is on Ubuntu 20.04. On MacOS 11.7.2 the black screen and error message appear for any photo. The declarative camera example on its own runs fine and does not display any errors. We did not see this error with Qt 5.12
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.cpp
The widget containing the QML is at:
https://github.com/martinburchell/qml-camera-example/blob/main/cameraqml.cpp
The 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 onImageCaptured and onImageSaved to ImageCapture
- a custom handler for onImageSavedToFile to PhotoPreview
- a custom fileNoLongerNeeded signal to tidy up saved images
The CameraButton onClicked handler sends the fileNoLongerNeeded signal 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 imageSavedToFile signal.