Important: Please read the Qt Code of Conduct -

QML Camera, focus on a custom point

  • Hi all,
    I need to focus a specific point in the display when capturing image with smartphone camera.
    The code I'm using is:

    Camera {
            id: camera
            focus {
                focusMode: Camera.FocusAuto
                focusPointMode: Camera.FocusPointCustom
        VideoOutput {
            id: videoView
            anchors.fill: parent
            fillMode: Image.PreserveAspectCrop
            source: camera
            autoOrientation: true
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    var point_x = mouse.x / Screen.width
                    var point_y = mouse.y / Screen.height
                    camera.focus.customFocusPoint = Qt.point(point_x, point_y)

    but every time I touch a point in the display it always focus on the center of the display. It seems to ignore the touched points.

    Where do I wrong?


Log in to reply