Qt 5.1:适用于相机的 QMultimedia 5.0

Qt 5.1: QMultimedia 5.0 in android for Camera

本文关键字:QMultimedia 相机 适用于 Qt      更新时间:2023-10-16

我想在Android中使用带有Qml界面和QtMultimedia 5.0的相机直到现在我还没有成功。

我正在使用Qt 5.1和qtquick 2.1和Android 4.2.2 API 17

这是我的代码:

主.qml :

import QtQuick 2.1
import QtMultimedia 5.0
Rectangle {
    width: 800
    height: 1280
    color:'green'
    Camera {
        id: camera
        imageCapture {
            onImageCaptured: {
                // Show the preview in an Image
                photoPreview.source = preview
            }
            onImageSaved: {
                text.text = qsTr("Last Captured Image (%1):").arg(camera.imageCapture.capturedImagePath)
            }
        }
    }
    Column {
        Text {
            height: 15
            text: qsTr("Preview (Click to capture):")
        }
        VideoOutput {
            source: camera
            focus: visible // To receive focus and capture key events when visible
            width: 320; height: 240
            MouseArea {
                anchors.fill: parent
                onClicked: camera.imageCapture.capture()
            }
        }
        Text {
            id: text
            height: 15
            text: qsTr("Last Captured Image (none)")
        }
        Image {
            id: photoPreview
            width: 320; height: 240
        }
    }
}

在 AndroidManifest 中.xml我添加了的文件:

<uses-feature android:name="android.hardware.camera" />

我得到的是白屏

提前致谢

如果您有

HTC设备,此错误可能是您没有视频输出的原因:QTBUG-43487。