我想在带有Qml接口和QtMultimedia 5.0的Android中使用相机直到现在我还没有成功。
我将 Qt 5.1 与 qtquick 2.1 和 Android 4.2.2 API 17 一起使用
这是我的代码:
main.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" />
我得到的是白屏
提前致谢