PySide6.QtMultimedia.QScreenCapture¶
- class QScreenCapture¶
- This class is used for capturing a screen. More… - Added in version 6.5. - Synopsis¶- Properties¶- activeᅟ- Whether the capturing is currently active
- errorᅟ- The code of the last error
- errorStringᅟ- Human readable string describing the cause of error
- screenᅟ- The screen for capturing
 - Methods¶- def - __init__()
- def - captureSession()
- def - error()
- def - errorString()
- def - isActive()
- def - screen()
- def - setScreen()
 - Slots¶- def - setActive()
- def - start()
- def - stop()
 - Signals¶- def - activeChanged()
- def - errorChanged()
- def - errorOccurred()
- def - screenChanged()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - The class captures a screen. It is managed by the - QMediaCaptureSessionclass where the captured screen can be displayed in a video preview object or recorded to a file.- session = QMediaCaptureSession() audioInput = QAudioInput() session.setAudioInput(input) recorder = QMediaRecorder() session.setRecorder(recorder) recorder.setQuality(QMediaRecorder.HighQuality) recorder.setOutputLocation(QUrl.fromLocalFile("test.mp3")) recorder.record() - Screen Capture Limitations¶- On Qt 6.5.2 and above, the following limitations apply to using - QScreenCapture:- It is only supported with the FFmpeg backend. 
- On Linux systems using the Wayland compositor, the screen capture implementation is experimental and comes with the following limitations. Due to restrictions of the Wayland protocol, it’s impossible to set and get the target screen via the API of the - QScreenCaptureclass. Instead, the OS will show a screen selection wizard upon invoking- QScreenCapture::setActive(true). The screen capture feature requires the installation of the ScreenCast service supported via XDG Desktop Portal and {https://pipewire.org/}{PipeWire} (0.3). These limitations might change in the future.
- It is not supported on mobile operating systems, except on Android. Screen Capture on Android needs additional Android foreground service permission to be added to the - AndroidManifest.xmlfile:- <manifest ...> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" /> <application ...> <service android:name="org.qtproject.qt.android.multimedia.QtScreenCaptureService" android:foregroundServiceType="mediaProjection" android:exported="false"/> </service> </application> </manifest> 
- On embedded with EGLFS, it has limited functionality. For Qt Quick applications, the class is currently implemented via QQuickWindow::grabWindow, which can cause performance issues. 
- In most cases, we set a screen capture frame rate that equals the screen refresh rate, except on Windows, where the rate might be flexible. Such a frame rate (75/120 FPS) might cause performance issues on weak CPUs if the captured screen is of 4K resolution. On EGLFS, the capture frame rate is currently locked to 30 FPS. 
 - See also - class Error¶
- Enumerates error codes that can be signaled by the - QScreenCaptureclass.- errorString()provides detailed information about the error cause.- Constant - Description - QScreenCapture.NoError - No error - QScreenCapture.InternalError - Internal screen capturing driver error - QScreenCapture.CapturingNotSupported - Capturing is not supported - QScreenCapture.CaptureFailed - Capturing screen failed - QScreenCapture.NotFound - Selected screen not found 
 - Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property activeᅟ: bool¶
 - This property holds whether the capturing is currently active.. - Access functions:
- Signal - activeChanged()
 
 - property errorᅟ: QScreenCapture.Error¶
 - This property holds the code of the last error.. - Access functions:
- Signal - errorChanged()
 
 - property errorStringᅟ: str¶
 - This property holds a human readable string describing the cause of error.. - Access functions:
- Signal - errorChanged()
 
 - This property holds the screen for capturing.. - Access functions:
- Signal - screenChanged()
 
 - activeChanged(arg__1)¶
- Parameters:
- arg__1 – bool 
 
 - Notification signal of property - activeᅟ.- captureSession()¶
- Return type:
 
 - Returns the capture session this - QScreenCaptureis connected to.- Use - setScreenCapture()to connect the camera to a session.- Getter of property - errorᅟ.- errorChanged()¶
 - Notification signal of property - errorᅟ.- Signals when an - erroroccurs, along with the- errorString.- errorString()¶
- Return type:
- str 
 
 - Getter of property - errorStringᅟ.- isActive()¶
- Return type:
- bool 
 
 - Getter of property - activeᅟ.- screen()¶
- Return type:
 - See also 
 - Getter of property - screenᅟ.- Notification signal of property - screenᅟ.- setActive(active)¶
- Parameters:
- active – bool 
 - See also 
 - Setter of property - activeᅟ.- Setter of property - screenᅟ.- start()¶
 - Starts screen capture. - stop()¶
 - Stops screen capture.