查看完整版本: [-- QML Camera问题 --]

QTCN开发网 -> Qt QML开发 -> QML Camera问题 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

songhuirong1 2019-12-06 08:13

QML Camera问题

写了一个小demo,功能是实现Camera的自动截图。程序能正常运行,但是发现Image无法显示中文路径的图片。望高手指点。
代码如下:
  1. import QtQuick 2.9
    import QtQuick.Window 2.2
    import QtMultimedia 5.8

    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Camera")
        property int btnHeight: 50

        Camera {
            id: camera
        }

        VideoOutput {
            anchors.fill: parent
            source: camera
        }

        Column {
            anchors.top: parent.top
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            anchors.bottomMargin: listView.height
            anchors.margins: 10
            width: 120
            spacing: 9

            Rectangle {
                id: takePhotoRect
                width: parent.width
                height: btnHeight
                color: "darkgray"
                border.width: 2
                border.color: "white"

                Text {
                    anchors.centerIn: parent
                    text: qsTr("Take Photo")
                    font.bold: true
                }

                MouseArea {
                    anchors.fill: parent

                    onClicked: {
                        camera.imageCapture.capture()
                    }
                }
            }

            Rectangle {
                id: playSequence
                width: parent.width
                height: btnHeight
                color: "darkgray"
                border.width: 2
                border.color: "white"

                Text {
                    anchors.centerIn: parent
                    text: qsTr("Play Sequence")
                    font.bold: true
                }

                MouseArea {
                    anchors.fill: parent

                    onClicked: {

                    }
                }
            }

            Rectangle {
                id: clearSequence
                width: parent.width
                height: btnHeight
                color: "darkgray"
                border.width: 2
                border.color: "white"

                Text {
                    anchors.centerIn: parent
                    text: qsTr("Clear Sequence")
                    font.bold: true
                }

                MouseArea {
                    anchors.fill: parent

                    onClicked: {

                    }
                }
            }
        }

        ListView {
            id: listView
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            width: parent.width
            height: 50
            orientation: ListView.Horizontal
            model: imgPathsModel
            delegate: Image {
                width: 50
                height: 50
                source: imgPath
            }
        }

        ListModel {
            id: imgPathsModel
        }

        Connections {
            target: camera.imageCapture

            onImageSaved: {
                console.log("path:", path)
                imgPathsModel.append({"imgPath": path})
            }
        }
    }

点击“Take Photo”按钮后,本地文件生成相应的图片文件,但是ListView里的Image显示报错。如下:
08:14:53: Starting E:\Qt_Project\build-Camera-Desktop_Qt_5_9_8_MinGW_32bit-Debug\debug\Camera.exe...
QML debugging is enabled. Only use this in a safe environment.
qml: path: C:/Users/宋慧荣/Pictures/IMG_00000019.jpg
qrc:/main.qml:109:19: QML Image: ????Ac?????????
08:16:20: E:/Qt_Project/build-Camera-Desktop_Qt_5_9_8_MinGW_32bit-Debug/debug/Camera.exe exited with code 0

songhuirong1 2019-12-09 13:11
没有人回答吗

songhuirong1 2019-12-11 14:04
这个问题没人知道吗?

nes9011 2019-12-19 17:28
请问你的Camera 能保存视频吗

simon261 2020-08-25 16:35
nes9011:请问你的Camera 能保存视频吗 (2019-12-19 17:28) 

可以,有个记录的控件。

simon261 2020-08-25 16:49
nes9011:请问你的Camera 能保存视频吗 (2019-12-19 17:28) 

CameraRecorder


查看完整版本: [-- QML Camera问题 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled