• 2650阅读
  • 5回复

[提问]QML Camera问题 [复制链接]

上一主题 下一主题
离线songhuirong1
 

只看楼主 倒序阅读 楼主  发表于: 2019-12-06
写了一个小demo,功能是实现Camera的自动截图。程序能正常运行,但是发现Image无法显示中文路径的图片。望高手指点。
代码如下:
  1. import QtQuick 2.9
  2. import QtQuick.Window 2.2
  3. import QtMultimedia 5.8
  4. Window {
  5.     visible: true
  6.     width: 640
  7.     height: 480
  8.     title: qsTr("Camera")
  9.     property int btnHeight: 50
  10.     Camera {
  11.         id: camera
  12.     }
  13.     VideoOutput {
  14.         anchors.fill: parent
  15.         source: camera
  16.     }
  17.     Column {
  18.         anchors.top: parent.top
  19.         anchors.right: parent.right
  20.         anchors.bottom: parent.bottom
  21.         anchors.bottomMargin: listView.height
  22.         anchors.margins: 10
  23.         width: 120
  24.         spacing: 9
  25.         Rectangle {
  26.             id: takePhotoRect
  27.             width: parent.width
  28.             height: btnHeight
  29.             color: "darkgray"
  30.             border.width: 2
  31.             border.color: "white"
  32.             Text {
  33.                 anchors.centerIn: parent
  34.                 text: qsTr("Take Photo")
  35.                 font.bold: true
  36.             }
  37.             MouseArea {
  38.                 anchors.fill: parent
  39.                 onClicked: {
  40.                     camera.imageCapture.capture()
  41.                 }
  42.             }
  43.         }
  44.         Rectangle {
  45.             id: playSequence
  46.             width: parent.width
  47.             height: btnHeight
  48.             color: "darkgray"
  49.             border.width: 2
  50.             border.color: "white"
  51.             Text {
  52.                 anchors.centerIn: parent
  53.                 text: qsTr("Play Sequence")
  54.                 font.bold: true
  55.             }
  56.             MouseArea {
  57.                 anchors.fill: parent
  58.                 onClicked: {
  59.                 }
  60.             }
  61.         }
  62.         Rectangle {
  63.             id: clearSequence
  64.             width: parent.width
  65.             height: btnHeight
  66.             color: "darkgray"
  67.             border.width: 2
  68.             border.color: "white"
  69.             Text {
  70.                 anchors.centerIn: parent
  71.                 text: qsTr("Clear Sequence")
  72.                 font.bold: true
  73.             }
  74.             MouseArea {
  75.                 anchors.fill: parent
  76.                 onClicked: {
  77.                 }
  78.             }
  79.         }
  80.     }
  81.     ListView {
  82.         id: listView
  83.         anchors.left: parent.left
  84.         anchors.right: parent.right
  85.         anchors.bottom: parent.bottom
  86.         width: parent.width
  87.         height: 50
  88.         orientation: ListView.Horizontal
  89.         model: imgPathsModel
  90.         delegate: Image {
  91.             width: 50
  92.             height: 50
  93.             source: imgPath
  94.         }
  95.     }
  96.     ListModel {
  97.         id: imgPathsModel
  98.     }
  99.     Connections {
  100.         target: camera.imageCapture
  101.         onImageSaved: {
  102.             console.log("path:", path)
  103.             imgPathsModel.append({"imgPath": path})
  104.         }
  105.     }
  106. }

点击“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

只看该作者 1楼 发表于: 2019-12-09
没有人回答吗
离线songhuirong1

只看该作者 2楼 发表于: 2019-12-11
这个问题没人知道吗?
离线nes9011

只看该作者 3楼 发表于: 2019-12-19
请问你的Camera 能保存视频吗
离线simon261

只看该作者 4楼 发表于: 2020-08-25
回 nes9011 的帖子
nes9011:请问你的Camera 能保存视频吗 (2019-12-19 17:28) 

可以,有个记录的控件。
离线simon261

只看该作者 5楼 发表于: 2020-08-25
回 nes9011 的帖子
nes9011:请问你的Camera 能保存视频吗 (2019-12-19 17:28) 

CameraRecorder
快速回复
限100 字节
 
上一个 下一个