捕获窗口 Qt 6.5

问题描述 投票:0回答:1

Qt 6.5 引入了

ScreenCapture
类,它应该记录屏幕。 检查一个例子

我试过以下方法:

ApplicationWindow {
  id: root

  MouseArea {
    id: recording
    anchors.fill: parent
    property bool inProcess: false
    onClicked: {
      if (recording.inProcess) {
        screenCapture.active = recording.inProcess = false;
        recorder.stop();  
      } else {
        screenCapture.active = recording.inProcess = true;
        recorder.record();
      }
    }
  }

  CaptureSession {
    id: captureSession
    screenCapture: ScreenCapture {
      id: screenCapture
      active: false
    }
    recorder: MediaRecorder {
      id: recorder
      mediaFormat {
        fileFormat: MediaFormat.MPEG4
        videoCodec: MediaFormat.VideoCodec.H265
      }
      outputLocation: "desired-name.mp4"
      quality: MediaRecorder.HighQuality
    }
  }
}

这就是工作!

但后来我想捕捉一个窗口,而不是整个屏幕。 由于documentation

ScreenCapture
有一个
window
属性来实现这一点,但是当我添加
window: root
到它,我得到一个错误:
Cannot assign to non-existent property "window"

它是 Qt 6.5 中的错误还是我遗漏了什么?

qt qml qtquick2 qt6 qtmultimedia
1个回答
0
投票

明白了,Qt6.5.0因为bug已经去掉了

© www.soinside.com 2019 - 2024. All rights reserved.