Qt 6.5 introduced ScreenCapture
class which should record a screen.
Check an example
I've tried the following:
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
}
}
}
And thats work!
But then I wanted to capture a window, not a whole screen.
Due to documentation, ScreenCapture
has a window
property to achieve that, but when I add
window: root
to it, I got an error: Cannot assign to non-existent property "window"
Is it bug in Qt 6.5 or I'm missing something?
I got it, Qt6.5.0 has removed it because of bugs.