连接滑块以控制qml Camera上的缩放

ned*_*eda 5 qt camera zoom qml

我正在用相机拍电影.
我想使用滑块缩放视频,如谷歌地图缩放.
在SO上发现了另一个问题但是建议的解决方案适用于click,而我想为滑块开发一个解决方案.
我编写的代码无法正常工作.我没有发现错误,但视频大小会非常大,然后我看不到视频.
我尝试将digitalZoom设置为相机,但我有这个错误: 相机不支持缩放..我知道我的相机不支持"DigitalZoom"和"OpticalZoom".我想找到一种方法来放大从相机拍摄的视频.
我的相机是dino ccd. 对不起朋友,我无法添加评论,我有这样的错误:"你必须有50个评论的声誉".

VideoOutput {
     id: viewfinder
     source: camera
     anchors.fill: parent
     focus : true                                
     transform: [
         Scale {
             id: zoomScale
         },
         Translate {
             id: zoomTranslate
         }
      ]

      //Keys.onLeftPressed: viewfinder.seek(viewfinder.position - 5000)
      //Keys.onRightPressed: viewfinder.seek(viewfinder.position + 5000)

      MouseArea {
           anchors.fill: parent
           acceptedButtons: Qt.AllButtons
           onClicked: {
              var zoomIn = mouse.button === Qt.LeftButton;
              zoomScale.origin.x = mouse.x;
              zoomScale.origin.y = mouse.y;
           }
      }

      Slider {
          id:zoomVideo
          orientation: Qt.Vertical
          minimumValue: 0
          maximumValue: 100
          stepSize: 10

          onValueChanged: {
              zoomScale.xScale = zoomVideo.value
              zoomScale.yScale = zoomVideo.value
          }
      }
  }
Run Code Online (Sandbox Code Playgroud)

Unk*_*own 0

您是否尝试使用滑块实现放大/缩小功能,就像普通的移动相机应用程序一样,如果是,请考虑下面未经测试的代码片段,因为目前我没有安装 Qt IDE 的机器,但它应该可以帮助你理解这个概念。

 Camera {
        id: camera
        digitalZoom:zoomSlider.value
        //if opticalZoom is supported uncomment below line
        //opticalZoom:zoomSlider.value

        // rest of your settings
    }

VideoOutput {
     id: viewfinder
     source: camera
     anchors.fill: parent
     focus : true  

     }

    Slider {
          id:zoomSlider
          orientation: Qt.Vertical
          minimumValue: 0
          maximumValue: camera.maximumDigitalZoom //or camera.maximumOpticalZoom
          stepSize:camera.maximumDigitalZoom/10   // going through 10 steps
          value:1.0                               // initial zoom level
          anchors{
           left:parent.left
           leftMargin:5
           verticalCenter:parent.verticalCenter
          }
      }
Run Code Online (Sandbox Code Playgroud)

我还希望您查看这些类型的官方文档。滑块相机。如果您需要进一步说明,请在下面发表评论。