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

此特性保持顯示視頻的調節亮度。

有效亮度值的範圍在 -100 到 100 之間,默認為 0。

訪問函數:

int brightness () const
void setBrightness (int brightness )

通知程序信號:

void brightnessChanged (int brightness )

contrast : int

此特性保持顯示視頻的調節對比度。

有效對比度值的範圍在 -100 到 100 之間,默認為 0。

訪問函數:

int contrast () const
void setContrast (int contrast )

通知程序信號:

void contrastChanged (int contrast )

fullScreen : bool

此特性保持視頻顯示是局限於窗口,還是全屏。

訪問函數:

bool isFullScreen () const
void setFullScreen (bool fullScreen )

通知程序信號:

void fullScreenChanged (bool fullScreen )

hue : int

此特性保持顯示視頻的調節色相。

有效色相值的範圍在 -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

此特性保持顯示視頻的調節飽和度。

有效飽和度值的範圍在 -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)

構造新視頻小部件。

The 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 ().

[虛擬] 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 .

返迴用於當前後端的大小提示 (若有 1 個),否則大小提示來自 QWidget .