Qt 5.11 | Qt Multimedia | C++ Classes | QVideoWidget

Qt 5.11.3 Reference Documentation

# QVideoWidget Class

The QVideoWidget class provides a widget which presents video produced by a media object. More...

Header: | #include <QVideoWidget>
qmake: | QT += multimediawidgets
Inherits: | QMediaBindableInterface and
Inherited By: | QCameraViewfinder

- List of all members, including inherited members

## Properties

- aspectRatioMode : Qt::AspectRatioMode
- brightness : int
- contrast : int
- fullScreen : bool

- hue : int
- mediaObject : QMediaObject* const
- saturation : int

## Public Functions

| 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

## Reimplemented Public Functions

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

- 1 public function inherited from QMediaBindableInterface

## Public Slots

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)

## Signals

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

## Reimplemented Protected Functions

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

- 1 protected function inherited from QMediaBindableInterface

## Detailed Description

The QVideoWidget class provides a widget which presents video produced by a media object.

Attaching a QVideoWidget to a QMediaObject allows it to display the video or image output of that media object. A QVideoWidget is attached to media object by passing a pointer to the QMediaObject in its constructor, and detached by destroying the 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();

Note: Only a single display output can be attached to a media object at one time.

See also QMediaObject, QMediaPlayer, and QGraphicsVideoItem.

## Property Documentation

### aspectRatioMode : Qt::AspectRatioMode

how video is scaled with respect to its aspect ratio.

Access functions:

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

### brightness : int

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

Valid brightness values range between -100 and 100, the default is 0.

Access functions:

int | brightness() const
void | setBrightness(int brightness)

Notifier signal:

void | brightnessChanged(int brightness)

### contrast : int

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

Valid contrast values range between -100 and 100, the default is 0.

Access functions:

int | contrast() const
void | setContrast(int contrast)

Notifier signal:

void | contrastChanged(int contrast)

### fullScreen : bool

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

Access functions:

bool | isFullScreen() const
void | setFullScreen(bool fullScreen)

Notifier signal:

void | fullScreenChanged(bool fullScreen)

### hue : int

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

Valid hue values range between -100 and 100, the default is 0.

Access functions:

int | hue() const
void | setHue(int hue)

Notifier signal:

void | hueChanged(int hue)

### mediaObject : QMediaObject* const

This property holds the media object which provides the video displayed by a widget.

Access functions:

virtual QMediaObject * | mediaObject() const override

### saturation : int

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

Valid saturation values range between -100 and 100, the default is 0.

Access functions:

int | saturation() const
void | setSaturation(int saturation)

Notifier signal:

void | saturationChanged(int saturation)

## Member Function Documentation

### QVideoWidget::QVideoWidget(QWidget *parent = nullptr)

Constructs a new video widget.

The parent is passed to QWidget.

### `[virtual]` QVideoWidget::~QVideoWidget()

Destroys a video widget.

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

Current event event. Returns the value of the baseclass QWidget::event(QEvent *event) function.

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

Handles the hide event.

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

Handles the move event.

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

Handles the paint event.

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

Handles the resize event.

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

Handles the show event.

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

Returns the size hint for the current back end, if there is one, or else the size hint from QWidget.