此类用于捕获屏幕。 更多...
头: | #include <QScreenCapture> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
qmake: | QT += multimedia |
Since: | Qt 6.5 |
实例化: | ScreenCapture |
继承: | QObject |
enum | Error { NoError, InternalError, CapturingNotSupported, CaptureFailed, NotFound } |
QMediaCaptureSession * | captureSession () const |
QScreenCapture::Error | error () const |
QString | errorString () const |
bool | isActive () const |
QScreen * | screen () const |
void | setScreen (QScreen * screen ) |
void | setActive (bool active ) |
void | start () |
void | stop () |
void | activeChanged (bool) |
void | errorChanged () |
void | errorOccurred (QScreenCapture::Error error , const QString & errorString ) |
void | screenChanged (QScreen *) |
The class captures a screen. It is managed by the QMediaCaptureSession class where the captured screen can be displayed in a video preview object or recorded to a file.
QMediaCaptureSession session; QAudioInput audioInput; session.setAudioInput(&input); QMediaRecorder recorder; session.setRecorder(&recorder); recorder.setQuality(QMediaRecorder::HighQuality); recorder.setOutputLocation(QUrl::fromLocalFile("test.mp3")); recorder.record();
On Qt 6.5.2 and above, the following limitations apply to using QScreenCapture:
另请参阅 QWindowCapture and QMediaCaptureSession .
Enumerates error codes that can be signaled by the QScreenCapture 类。 errorString () provides detailed information about the error cause.
常量 | 值 | 描述 |
---|---|---|
QScreenCapture::NoError
|
0
|
没有错误 |
QScreenCapture::InternalError
|
1
|
内部屏幕捕获驱动程序错误 |
QScreenCapture::CapturingNotSupported
|
2
|
不支持捕获 |
QScreenCapture::CaptureFailed
|
4
|
捕获屏幕失败 |
QScreenCapture::NotFound
|
5
|
找不到选中屏幕 |
此特性保持捕获目前是否活动。
访问函数:
bool | isActive () const |
void | setActive (bool active ) |
通知程序信号:
void | activeChanged (bool) |
[read-only]
error
: const
Error
This property holds the code of the last error.
访问函数:
QScreenCapture::Error | error () const |
通知程序信号:
void | errorChanged () |
[read-only]
errorString
: const
QString
This property holds a human readable string describing the cause of error.
访问函数:
QString | errorString () const |
通知程序信号:
void | errorChanged () |
此特性保持用于捕获的屏幕。
访问函数:
QScreen * | screen () const |
void | setScreen (QScreen * screen ) |
通知程序信号:
void | screenChanged (QScreen *) |
Returns the capture session this QScreenCapture is connected to.
使用 QMediaCaptureSession::setScreenCapture () to connect the camera to a session.
[signal]
void
QScreenCapture::
errorOccurred
(
QScreenCapture::Error
error
, const
QString
&
errorString
)
Signals when an error occurs, along with the errorString .
[slot]
void
QScreenCapture::
start
()
启动屏幕捕获。
[slot]
void
QScreenCapture::
stop
()
停止屏幕捕获。