- Qt 6.12
- Qt Multimedia
- C++ Classes
- QtMultimediaWidgets
- QVideoWidget
- Qt 6.12.0 Reference Documentation

# QVideoWidget Class

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

Header: | `#include <qvideowidget.h>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS MultimediaWidgets)` `target_link_libraries(mytarget PRIVATE Qt6::MultimediaWidgets)`
qmake: | `QT += multimediawidgets`
Inherits: | QWidget

- List of all members, including inherited members

## Properties

- aspectRatioMode : Qt::AspectRatioMode
- fullScreen : bool

## Public Functions

| QVideoWidget(QWidget *parent = nullptr)
virtual | ~QVideoWidget() override
Qt::AspectRatioMode | aspectRatioMode() const
bool | isFullScreen() const
QVideoSink * | videoSink() const

## Reimplemented Public Functions

virtual QSize | sizeHint() const override

## Public Slots

void | setAspectRatioMode(Qt::AspectRatioMode mode)
void | setFullScreen(bool fullScreen)

## Signals

void | aspectRatioModeChanged(Qt::AspectRatioMode mode)
void | fullScreenChanged(bool fullScreen)

## Reimplemented Protected Functions

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

## Detailed Description

Attaching a QVideoWidget to a QMediaPlayer or QCamera allows it to display the video or image output of that object.

     player = new QMediaPlayer;
     player->setSource(QUrl("http://example.com/myclip1.mp4"));

     videoWidget = new QVideoWidget;
     player->setVideoOutput(videoWidget);

     videoWidget->show();
     player->play();

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

Warning: QVideoWidget is not supported on the `eglfs` platform plugin.

See also QCamera, 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)

Notifier signal:

void | aspectRatioModeChanged(Qt::AspectRatioMode mode)

### 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)

## Member Function Documentation

### `[explicit]` QVideoWidget::QVideoWidget(QWidget *parent = nullptr)

Constructs a new video widget.

The parent is passed to QWidget.

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

Destroys a video widget.

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

Reimplements: QWidget::event(QEvent *event).

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

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

Reimplements: QWidget::hideEvent(QHideEvent *event).

Handles the hide event.

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

Reimplements: QWidget::moveEvent(QMoveEvent *event).

Handles the move event.

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

Reimplements: QWidget::resizeEvent(QResizeEvent *event).

Handles the resize event.

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

Reimplements: QWidget::showEvent(QShowEvent *event).

Handles the show event.

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

Reimplements an access function for property: QWidget::sizeHint.

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

### `[invokable]` QVideoSink *QVideoWidget::videoSink() const

Returns the QVideoSink instance.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.