QVideoWidget 类

QVideoWidget 类提供呈现媒体对象产生视频的小部件。 更多...

头: #include <QVideoWidget>
qmake: QT += multimediawidgets
继承: QWidget and QMediaBindableInterface
继承者:

QCameraViewfinder

特性

公共函数

QVideoWidget (QWidget * parent = nullptr)
virtual ~QVideoWidget ()
Qt::AspectRatioMode aspectRatioMode () const
int brightness () const
int contrast () const
int hue () const
bool isFullScreen () const
int saturation () const
QAbstractVideoSurface * videoSurface () const

重实现公共函数

virtual QMediaObject * mediaObject () const override
virtual QSize sizeHint () const override

公共槽

void setAspectRatioMode (Qt::AspectRatioMode mode )
void setBrightness (int brightness )
void setContrast (int contrast )
void setFullScreen (bool fullScreen )
void setHue (int hue )
void setSaturation (int saturation )

信号

void brightnessChanged (int brightness )
void contrastChanged (int contrast )
void fullScreenChanged (bool fullScreen )
void hueChanged (int hue )
void saturationChanged (int saturation )

重实现保护函数

virtual bool event (QEvent * event ) override
virtual void hideEvent (QHideEvent * event ) override
virtual void moveEvent (QMoveEvent * event ) override
virtual void paintEvent (QPaintEvent * event ) override
virtual void resizeEvent (QResizeEvent * event ) override
virtual void showEvent (QShowEvent * event ) override

详细描述

附加 QVideoWidget 到 QMediaObject 允许它显示该媒体对象的视频 (或图像) 输出。QVideoWidget 被附加到媒体对象,通过传递指针给 QMediaObject 在其构造函数,并通过销毁 QVideoWidget 分离。

player = new QMediaPlayer;
playlist = new QMediaPlaylist(player);
playlist->addMedia(QUrl("http://example.com/myclip1.mp4"));
playlist->addMedia(QUrl("http://example.com/myclip2.mp4"));
videoWidget = new QVideoWidget;
player->setVideoOutput(videoWidget);
videoWidget->show();
playlist->setCurrentIndex(1);
player->play();
					

注意 :每次只可以把单个显示输出附加到媒体对象。

另请参阅 QMediaObject , QMediaPlayer ,和 QGraphicsVideoItem .

特性文档编制

aspectRatioMode : Qt::AspectRatioMode

视频如何比例缩放根据其宽高比。

访问函数:

Qt::AspectRatioMode aspectRatioMode () const
void setAspectRatioMode (Qt::AspectRatioMode mode )

brightness : int

This property holds an adjustment to the brightness of displayed video.

有效亮度值的范围在 -100 到 100 之间,默认为 0。

访问函数:

int brightness () const
void setBrightness (int brightness )

通知程序信号:

void brightnessChanged (int brightness )

contrast : int

This property holds an adjustment to the contrast of displayed video.

有效对比度值的范围在 -100 到 100 之间,默认为 0。

访问函数:

int contrast () const
void setContrast (int contrast )

通知程序信号:

void contrastChanged (int contrast )

fullScreen : bool

This property holds whether video display is confined to a window or is fullScreen.

访问函数:

bool isFullScreen () const
void setFullScreen (bool fullScreen )

通知程序信号:

void fullScreenChanged (bool fullScreen )

hue : int

This property holds an adjustment to the hue of displayed video.

有效色相值的范围在 -100 到 100 之间,默认为 0。

访问函数:

int hue () const
void setHue (int hue )

通知程序信号:

void hueChanged (int hue )

mediaObject : QMediaObject * const

此特性保持提供 Widget 显示视频的媒体对象。

访问函数:

virtual QMediaObject * mediaObject () const override

saturation : int

This property holds an adjustment to the saturation of displayed video.

有效饱和度值的范围在 -100 至 100 之间,默认为 0。

访问函数:

int saturation () const
void setSaturation (int saturation )

通知程序信号:

void saturationChanged (int saturation )

videoSurface : QAbstractVideoSurface * const

返回可以将视频帧渲染到当前 Widget 的底层视频表面。此特性从不为 nullptr 。范例展示如何将视频帧渲染到 QVideoWidget :

QImage img = QImage("images/qt-logo.png").convertToFormat(QImage::Format_ARGB32);
QVideoSurfaceFormat format(img.size(), QVideoFrame::Format_ARGB32);
videoWidget = new QVideoWidget;
videoWidget->videoSurface()->start(format);
videoWidget->videoSurface()->present(img);
videoWidget->show();
					

该特性在 Qt 5.15 引入。

访问函数:

QAbstractVideoSurface * videoSurface () const

另请参阅 QMediaPlayer::setVideoOutput .

成员函数文档编制

QVideoWidget:: QVideoWidget ( QWidget * parent = nullptr)

构造新视频小部件。

parent 会被传递给 QWidget .

[signal] void QVideoWidget:: brightnessChanged ( int brightness )

信号视频 Widget 的 brightness 调节已改变。

注意: 通知程序信号对于特性 brightness .

另请参阅 brightness ().

[signal] void QVideoWidget:: contrastChanged ( int contrast )

信号视频 Widget 的 contrast 调节已改变。

注意: 通知程序信号对于特性 contrast .

另请参阅 contrast ().

[signal] void QVideoWidget:: fullScreenChanged ( bool fullScreen )

信号 fullScreen 视频 Widget 模式已改变。

注意: 通知程序信号对于特性 fullScreen .

另请参阅 isFullScreen ().

[signal] void QVideoWidget:: hueChanged ( int hue )

信号视频 Widget 的 hue 已改变。

注意: 通知程序信号对于特性 hue .

另请参阅 hue ().

[signal] void QVideoWidget:: saturationChanged ( int saturation )

信号视频 Widget 的 saturation 已改变。

注意: 通知程序信号对于特性 saturation .

另请参阅 saturation ().

[virtual] QVideoWidget:: ~QVideoWidget ()

销毁视频小部件。

[override virtual protected] bool QVideoWidget:: event ( QEvent * event )

重实现: QWidget::event (QEvent *event).

当前事件 event 。返回值为基类 QWidget::event ( QEvent *event) 函数。

[override virtual protected] void QVideoWidget:: hideEvent ( QHideEvent * event )

重实现: QWidget::hideEvent (QHideEvent *event).

处理隐藏 event .

[override virtual protected] void QVideoWidget:: moveEvent ( QMoveEvent * event )

重实现: QWidget::moveEvent (QMoveEvent *event).

处理移动 event .

[override virtual protected] void QVideoWidget:: paintEvent ( QPaintEvent * event )

重实现: QWidget::paintEvent (QPaintEvent *event).

处理描绘 event .

[override virtual protected] void QVideoWidget:: resizeEvent ( QResizeEvent * event )

重实现: QWidget::resizeEvent (QResizeEvent *event).

处理重置尺寸 event .

[override virtual protected] void QVideoWidget:: showEvent ( QShowEvent * event )

重实现: QWidget::showEvent (QShowEvent *event).

处理展示 event .

[override virtual] QSize QVideoWidget:: sizeHint () const

重实现访问函数为特性: QWidget::sizeHint .

返回用于当前后端的大小提示 (若有一个的话),否则大小提示来自 QWidget .