QWindowCapture Class

该类用于捕捉窗口。更多

Header: #include <QWindowCapture>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia
Qt 6.6
在 QML 中: WindowCapture
继承: QObject

公共类型

enum Error { NoError, InternalError, CapturingNotSupported, CaptureFailed, NotFound }

属性

公共功能

QWindowCapture(QObject *parent = nullptr)
virtual ~QWindowCapture() override
QWindowCapture::Error error() const
QString errorString() const
bool isActive() const
void setWindow(QCapturableWindow window)
QCapturableWindow window() const

公共插槽

void setActive(bool active)
void start()
void stop()

信号

void activeChanged(bool)
void errorChanged()
void errorOccurred(QWindowCapture::Error error, const QString &errorString)
void windowChanged(QCapturableWindow window)

静态公共成员

QList<QCapturableWindow> capturableWindows()

详细说明

该类用于捕获窗口。该类由QMediaCaptureSession 类管理,捕获的窗口可显示在视频预览对象中或录制到文件中。

窗口捕获限制

使用 QWindowCapture 时有以下限制:

  • QWindowCapture 仅支持 FFmpeg 后端。

另请参阅 QMediaCaptureSessionQCapturableWindow

成员类型文档

enum QWindowCapture::Error

枚举了可由QWindowCapture 类发出信号的错误代码。errorString() 提供有关错误原因的详细信息。

常量说明
QWindowCapture::NoError0无错误
QWindowCapture::InternalError1窗口捕捉驱动程序内部错误
QWindowCapture::CapturingNotSupported2不支持窗口捕捉
QWindowCapture::CaptureFailed4捕捉窗口失败
QWindowCapture::NotFound5未找到选定窗口

属性文档

active : bool

该属性显示捕捉当前是否处于活动状态。

访问功能:

bool isActive() const
void setActive(bool active)

Notifier 信号:

void activeChanged(bool)

另请参阅 start() 和stop()。

[read-only] error : const Error

该属性保存上次错误的代码。

访问功能:

QWindowCapture::Error error() const

通知信号:

void errorChanged()

[read-only] errorString : const QString

该属性包含一个人可读字符串,用于描述错误原因。

访问功能:

QString errorString() const

Notifier 信号:

void errorChanged()

window : QCapturableWindow

该属性用于保存捕捉窗口。

访问功能:

QCapturableWindow window() const
void setWindow(QCapturableWindow window)

Notifier 信号:

void windowChanged(QCapturableWindow window)

另请参阅 QWindowCapture::capturableWindows

成员函数文档

[explicit] QWindowCapture::QWindowCapture(QObject *parent = nullptr)

parent 构建一个新的 QWindowCapture 对象。

[override virtual noexcept] QWindowCapture::~QWindowCapture()

销毁对象。

[static invokable] QList<QCapturableWindow> QWindowCapture::capturableWindows()

返回可用于捕获的QCapturableWindow 对象列表。

注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE

[signal] void QWindowCapture::errorOccurred(QWindowCapture::Error error, const QString &errorString)

error 时发出信号,同时发出errorString

[slot] void QWindowCapture::start()

开始捕获window

这相当于将active 属性设置为 true。

[slot] void QWindowCapture::stop()

停止捕获。

这相当于将active 属性设置为 false。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.