How to capture pictures in a Qt Android Application?

72 views Asked by At

I'm developing an Android application using Qt (6.6.1), and trying to implement a feature to capture pictures using the device's camera. I'm relatively new to integrating Qt with Android-specific features, and I'm struggling with how to correctly implement the camera functionality.

I've attempted to use first a C++ approach, but it didn't work, and then I tried to solve that only using QML, but my main.qml is not able to recognize "source" down below.

I got this message:

"invalid property name source". (M16)

Camera {
    id: camera
}

VideoOutput {
    source: camera
    anchors.fill: parent
}

Component.onCompleted: {
    camera.start()
}

I don't know how to access the camera and also how to display the camera feed on the screen. I wasn't able to initiate the camera at all.

1

There are 1 answers

3
Luca Carlon On

You probably looked at the wrong Qt version. No source property exists for VideoOutput: https://doc.qt.io/qt-6/qml-qtmultimedia-videooutput.html.

You'll find an example there. Also look here: https://doc.qt.io/qt-6/qml-qtmultimedia-camera.html.